@ledgerhq/context-module 1.10.0 → 1.11.1
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/lib/cjs/package.json +38 -34
- package/lib/cjs/src/DefaultContextModule.test.js.map +1 -1
- package/lib/cjs/src/di.js +1 -1
- package/lib/cjs/src/di.js.map +3 -3
- package/lib/cjs/src/index.js +1 -1
- package/lib/cjs/src/index.js.map +2 -2
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js +1 -1
- package/lib/cjs/src/shared/domain/ContextFieldLoader.js.map +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +1 -1
- package/lib/cjs/src/shared/model/SolanaContextTypes.js +2 -0
- package/lib/cjs/src/shared/model/SolanaContextTypes.js.map +7 -0
- package/lib/cjs/src/shared/model/SolanaTransactionContext.js +1 -1
- package/lib/cjs/src/shared/model/SolanaTransactionContext.js.map +1 -1
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
- package/lib/cjs/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +2 -2
- package/lib/cjs/src/solana/data/SolanaDataSource.js +1 -1
- package/lib/cjs/src/solana/data/SolanaDataSource.js.map +1 -1
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
- package/lib/cjs/src/solana/domain/DefaultSolanaContextLoader.test.js.map +3 -3
- package/lib/cjs/src/solana/domain/solanaContextTypes.js +1 -1
- package/lib/cjs/src/solana/domain/solanaContextTypes.js.map +1 -1
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js +2 -0
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +7 -0
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +2 -0
- package/lib/cjs/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +7 -0
- package/lib/cjs/src/solanaLifi/data/SolanaLifiDataSource.js +2 -0
- package/lib/cjs/src/solanaLifi/data/SolanaLifiDataSource.js.map +7 -0
- package/lib/cjs/src/solanaLifi/di/lifiModuleFactory.js +2 -0
- package/lib/cjs/src/solanaLifi/di/lifiModuleFactory.js.map +7 -0
- package/lib/cjs/src/solanaLifi/di/solanaLifiTypes.js +2 -0
- package/lib/cjs/src/solanaLifi/di/solanaLifiTypes.js.map +7 -0
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js +2 -0
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +7 -0
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +2 -0
- package/lib/cjs/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +7 -0
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js +2 -0
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +7 -0
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +7 -0
- package/lib/cjs/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +7 -0
- package/lib/cjs/src/solanaToken/data/SolanaTokenDataSource.js +2 -0
- package/lib/cjs/src/solanaToken/data/SolanaTokenDataSource.js.map +7 -0
- package/lib/cjs/src/solanaToken/di/solanaTokenTypes.js +2 -0
- package/lib/cjs/src/solanaToken/di/solanaTokenTypes.js.map +7 -0
- package/lib/cjs/src/solanaToken/di/tokenModuleFactory.js +2 -0
- package/lib/cjs/src/solanaToken/di/tokenModuleFactory.js.map +7 -0
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js +2 -0
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.js.map +7 -0
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js +2 -0
- package/lib/cjs/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +7 -0
- package/lib/esm/package.json +38 -34
- package/lib/esm/src/DefaultContextModule.test.js.map +1 -1
- package/lib/esm/src/di.js +1 -1
- package/lib/esm/src/di.js.map +3 -3
- package/lib/esm/src/index.js +1 -1
- package/lib/esm/src/index.js.map +2 -2
- package/lib/esm/src/shared/model/ClearSignContext.js +1 -1
- package/lib/esm/src/shared/model/ClearSignContext.js.map +1 -1
- package/lib/esm/src/shared/model/SolanaContextTypes.js +2 -0
- package/lib/esm/src/shared/model/SolanaContextTypes.js.map +7 -0
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js +1 -1
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.js.map +3 -3
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js +1 -1
- package/lib/esm/src/solana/data/HttpSolanaOwnerInfoDataSource.test.js.map +2 -2
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js +1 -1
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.js.map +3 -3
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js +1 -1
- package/lib/esm/src/solana/domain/DefaultSolanaContextLoader.test.js.map +3 -3
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js +2 -0
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.js.map +7 -0
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js +2 -0
- package/lib/esm/src/solanaLifi/data/HttpSolanaLifiDataSource.test.js.map +7 -0
- package/lib/esm/src/solanaLifi/data/SolanaLifiDataSource.js +1 -0
- package/lib/esm/src/solanaLifi/data/SolanaLifiDataSource.js.map +7 -0
- package/lib/esm/src/solanaLifi/di/lifiModuleFactory.js +2 -0
- package/lib/esm/src/solanaLifi/di/lifiModuleFactory.js.map +7 -0
- package/lib/esm/src/solanaLifi/di/solanaLifiTypes.js +2 -0
- package/lib/esm/src/solanaLifi/di/solanaLifiTypes.js.map +7 -0
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js +2 -0
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.js.map +7 -0
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js +2 -0
- package/lib/esm/src/solanaLifi/domain/SolanaLifiContextLoader.test.js.map +7 -0
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js +2 -0
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.js.map +7 -0
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js +7 -0
- package/lib/esm/src/solanaToken/data/HttpSolanaTokenDataSource.test.js.map +7 -0
- package/lib/esm/src/solanaToken/data/SolanaTokenDataSource.js +1 -0
- package/lib/esm/src/solanaToken/data/SolanaTokenDataSource.js.map +7 -0
- package/lib/esm/src/solanaToken/di/solanaTokenTypes.js +2 -0
- package/lib/esm/src/solanaToken/di/solanaTokenTypes.js.map +7 -0
- package/lib/esm/src/solanaToken/di/tokenModuleFactory.js +2 -0
- package/lib/esm/src/solanaToken/di/tokenModuleFactory.js.map +7 -0
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js +2 -0
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.js.map +7 -0
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js +2 -0
- package/lib/esm/src/solanaToken/domain/SolanaTokenContextLoader.test.js.map +7 -0
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +2 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts +14 -4
- package/lib/types/src/shared/domain/ContextFieldLoader.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +59 -32
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/shared/model/SolanaContextTypes.d.ts +47 -0
- package/lib/types/src/shared/model/SolanaContextTypes.d.ts.map +1 -0
- package/lib/types/src/shared/model/SolanaTransactionContext.d.ts +2 -0
- package/lib/types/src/shared/model/SolanaTransactionContext.d.ts.map +1 -1
- package/lib/types/src/solana/data/HttpSolanaOwnerInfoDataSource.d.ts.map +1 -1
- package/lib/types/src/solana/data/SolanaDataSource.d.ts +1 -4
- package/lib/types/src/solana/data/SolanaDataSource.d.ts.map +1 -1
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts +5 -3
- package/lib/types/src/solana/domain/DefaultSolanaContextLoader.d.ts.map +1 -1
- package/lib/types/src/solana/domain/solanaContextTypes.d.ts +7 -5
- package/lib/types/src/solana/domain/solanaContextTypes.d.ts.map +1 -1
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts +9 -0
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.d.ts.map +1 -0
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.test.d.ts +2 -0
- package/lib/types/src/solanaLifi/data/HttpSolanaLifiDataSource.test.d.ts.map +1 -0
- package/lib/types/src/solanaLifi/data/SolanaLifiDataSource.d.ts +13 -0
- package/lib/types/src/solanaLifi/data/SolanaLifiDataSource.d.ts.map +1 -0
- package/lib/types/src/solanaLifi/di/lifiModuleFactory.d.ts +3 -0
- package/lib/types/src/solanaLifi/di/lifiModuleFactory.d.ts.map +1 -0
- package/lib/types/src/solanaLifi/di/solanaLifiTypes.d.ts +5 -0
- package/lib/types/src/solanaLifi/di/solanaLifiTypes.d.ts.map +1 -0
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts +16 -0
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.d.ts.map +1 -0
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.test.d.ts +2 -0
- package/lib/types/src/solanaLifi/domain/SolanaLifiContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts +9 -0
- package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.d.ts.map +1 -0
- package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.test.d.ts +2 -0
- package/lib/types/src/solanaToken/data/HttpSolanaTokenDataSource.test.d.ts.map +1 -0
- package/lib/types/src/solanaToken/data/SolanaTokenDataSource.d.ts +44 -0
- package/lib/types/src/solanaToken/data/SolanaTokenDataSource.d.ts.map +1 -0
- package/lib/types/src/solanaToken/di/solanaTokenTypes.d.ts +5 -0
- package/lib/types/src/solanaToken/di/solanaTokenTypes.d.ts.map +1 -0
- package/lib/types/src/solanaToken/di/tokenModuleFactory.d.ts +3 -0
- package/lib/types/src/solanaToken/di/tokenModuleFactory.d.ts.map +1 -0
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts +22 -0
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.d.ts.map +1 -0
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.test.d.ts +2 -0
- package/lib/types/src/solanaToken/domain/SolanaTokenContextLoader.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +36 -32
package/lib/cjs/package.json
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"axios": "catalog:",
|
|
4
|
+
"crypto-js": "catalog:",
|
|
5
|
+
"ethers": "catalog:",
|
|
6
|
+
"inversify": "catalog:",
|
|
7
|
+
"purify-ts": "catalog:",
|
|
8
|
+
"reflect-metadata": "catalog:"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@ledgerhq/device-management-kit": "workspace:^",
|
|
12
|
+
"@ledgerhq/eslint-config-dsdk": "workspace:^",
|
|
13
|
+
"@ledgerhq/ldmk-tool": "workspace:^",
|
|
14
|
+
"@ledgerhq/prettier-config-dsdk": "workspace:^",
|
|
15
|
+
"@ledgerhq/tsconfig-dsdk": "workspace:^",
|
|
16
|
+
"@ledgerhq/vitest-config-dmk": "workspace:^",
|
|
17
|
+
"@types/crypto-js": "catalog:",
|
|
18
|
+
"ts-node": "catalog:"
|
|
19
|
+
},
|
|
6
20
|
"exports": {
|
|
7
21
|
".": {
|
|
8
|
-
"types": "./lib/types/index.d.ts",
|
|
9
22
|
"import": "./lib/esm/index.js",
|
|
10
|
-
"require": "./lib/cjs/index.js"
|
|
23
|
+
"require": "./lib/cjs/index.js",
|
|
24
|
+
"types": "./lib/types/index.d.ts"
|
|
11
25
|
},
|
|
12
26
|
"./*": {
|
|
13
|
-
"types": "./lib/types/*",
|
|
14
27
|
"import": "./lib/esm/*",
|
|
15
|
-
"require": "./lib/cjs/*"
|
|
28
|
+
"require": "./lib/cjs/*",
|
|
29
|
+
"types": "./lib/types/*"
|
|
16
30
|
}
|
|
17
31
|
},
|
|
18
32
|
"files": [
|
|
19
33
|
"./lib"
|
|
20
34
|
],
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"name": "@ledgerhq/context-module",
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@ledgerhq/device-management-kit": "workspace:^"
|
|
39
|
+
},
|
|
40
|
+
"private": false,
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/LedgerHQ/device-sdk-ts.git"
|
|
44
|
+
},
|
|
21
45
|
"scripts": {
|
|
22
|
-
"prebuild": "rimraf lib",
|
|
23
46
|
"build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
24
47
|
"dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
|
|
25
|
-
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
26
|
-
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
|
|
27
48
|
"lint": "eslint",
|
|
28
49
|
"lint:fix": "pnpm lint --fix",
|
|
29
50
|
"postpack": "find . -name '*.tgz' -exec cp {} ../../../dist/ \\; ",
|
|
51
|
+
"prebuild": "rimraf lib",
|
|
30
52
|
"prettier": "prettier . --check",
|
|
31
53
|
"prettier:fix": "prettier . --write",
|
|
32
54
|
"test": "vitest run",
|
|
33
|
-
"test:watch": "vitest",
|
|
34
55
|
"test:coverage": "vitest run --coverage",
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"@ledgerhq/ldmk-tool": "workspace:*",
|
|
40
|
-
"@ledgerhq/eslint-config-dsdk": "workspace:*",
|
|
41
|
-
"@ledgerhq/prettier-config-dsdk": "workspace:*",
|
|
42
|
-
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
43
|
-
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
44
|
-
"@types/crypto-js": "catalog:",
|
|
45
|
-
"ts-node": "catalog:"
|
|
46
|
-
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"axios": "catalog:",
|
|
49
|
-
"crypto-js": "catalog:",
|
|
50
|
-
"ethers": "catalog:",
|
|
51
|
-
"inversify": "catalog:",
|
|
52
|
-
"purify-ts": "catalog:",
|
|
53
|
-
"reflect-metadata": "catalog:"
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"typecheck": "tsc --noEmit",
|
|
58
|
+
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
59
|
+
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
54
60
|
},
|
|
55
|
-
"
|
|
56
|
-
"@ledgerhq/device-management-kit": "workspace:*"
|
|
57
|
-
}
|
|
61
|
+
"version": "1.11.1"
|
|
58
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/DefaultContextModule.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn(),\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
|
|
4
|
+
"sourcesContent": ["import { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"./shared/model/ClearSignContext\";\nimport { type TypedDataContext } from \"./shared/model/TypedDataContext\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\nconst contextLoaderStubBuilder = (canHandle: boolean): ContextLoader => {\n return {\n load: vi.fn(),\n canHandle: vi\n .fn()\n .mockReturnValue(canHandle) as unknown as ContextLoader[\"canHandle\"],\n };\n};\n\nconst fieldLoaderStubBuilder = (): ContextFieldLoader => {\n return {\n canHandle: vi.fn() as unknown as ContextFieldLoader[\"canHandle\"],\n loadField: vi.fn(),\n };\n};\n\ndescribe(\"DefaultContextModule\", () => {\n const typedDataLoader: TypedDataContextLoader = { load: vi.fn() };\n const defaultContextModuleConfig: ContextModuleConfig = {\n customLoaders: [],\n defaultLoaders: false,\n defaultFieldLoaders: false,\n customFieldLoaders: [],\n customTypedDataLoader: typedDataLoader,\n cal: {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n web3checks: {\n url: \"https://web3checks/v3\",\n },\n metadataServiceDomain: {\n url: \"https://metadata.com\",\n },\n originToken: \"originToken\",\n };\n\n beforeEach(() => {\n vi.restoreAllMocks();\n });\n\n it(\"should initialize the context module with all the default loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should return an empty array when no loaders\", async () => {\n const contextModule = new DefaultContextModule(defaultContextModuleConfig);\n\n const res = await contextModule.getContexts({});\n\n expect(res).toEqual([]);\n });\n\n it(\"should call all fetch method from metadata fetcher\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return an array of context response\", async () => {\n const loader = contextLoaderStubBuilder(true);\n const responses = [\n [{ type: \"provideERC20Info\", payload: \"payload1\" }],\n [\n { type: \"provideERC20Info\", payload: \"payload2\" },\n { type: \"plugin\", payload: \"payload3\" },\n ],\n ] as ClearSignContext[][];\n vi.spyOn(loader, \"load\")\n .mockResolvedValueOnce(responses[0]!)\n .mockResolvedValueOnce(responses[1]!);\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader, loader],\n });\n\n const res = await contextModule.getContexts({});\n\n expect(loader.canHandle).toHaveBeenCalledTimes(2);\n expect(loader.load).toHaveBeenCalledTimes(2);\n expect(res).toEqual(responses.flat());\n });\n\n it(\"should only call loaders that can handle the input\", async () => {\n const loader1 = contextLoaderStubBuilder(true);\n const loader2 = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(loader2, \"canHandle\").mockReturnValue(false);\n vi.spyOn(loader1, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n vi.spyOn(loader2, \"load\").mockResolvedValue([\n { type: ClearSignContextType.NFT, payload: \"payload2\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader1, loader2],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n const res = await contextModule.getContexts(testInput);\n\n expect(loader1.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader2.canHandle).toHaveBeenCalledWith(\n testInput,\n Object.values(ClearSignContextType),\n );\n expect(loader1.load).toHaveBeenCalledWith(testInput);\n expect(loader2.load).not.toHaveBeenCalled(); // Should not be called since canHandle returned false\n expect(res).toEqual([{ type: \"token\", payload: \"payload1\" }]);\n });\n\n it(\"should use expected types if provided\", async () => {\n const loader = contextLoaderStubBuilder(true);\n\n vi.spyOn(loader, \"canHandle\").mockReturnValue(true);\n\n vi.spyOn(loader, \"load\").mockResolvedValue([\n { type: ClearSignContextType.TOKEN, payload: \"payload1\" },\n ]);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [loader],\n });\n\n const testInput = { to: \"0x123\", selector: \"0xabc\" };\n await contextModule.getContexts(testInput, [ClearSignContextType.TOKEN]);\n\n expect(loader.canHandle).toHaveBeenCalledWith(testInput, [\n ClearSignContextType.TOKEN,\n ]);\n });\n\n it(\"should call the typed data loader\", async () => {\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customTypedDataLoader: typedDataLoader,\n });\n\n await contextModule.getTypedDataFilters({} as TypedDataContext);\n\n expect(typedDataLoader.load).toHaveBeenCalledTimes(1);\n });\n\n describe(\"getFieldContext\", () => {\n it(\"should return error when no loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(false);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"unknown\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).not.toHaveBeenCalled();\n expect(result).toEqual({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${testField} and expected type: ${ClearSignContextType.TOKEN}`,\n ),\n });\n });\n\n it(\"should return context when a loader can handle the field\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const mockContext: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"test-payload\",\n };\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockResolvedValue(mockContext);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"token\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext);\n });\n\n it(\"should return first context when multiple loaders can handle the field\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"first-payload\",\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.NFT,\n payload: \"second-payload\",\n };\n\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"multi\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).not.toHaveBeenCalled();\n expect(result).toEqual(mockContext1); // Should return first context\n });\n\n it(\"should return second context when first context is an error\", async () => {\n // GIVEN\n const fieldLoader1 = fieldLoaderStubBuilder();\n const fieldLoader2 = fieldLoaderStubBuilder();\n const mockContext1: ClearSignContext = {\n type: ClearSignContextType.ERROR,\n error: new Error(\"first-error\"),\n };\n const mockContext2: ClearSignContext = {\n type: ClearSignContextType.TOKEN,\n payload: \"second-payload\",\n };\n vi.spyOn(fieldLoader1, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader2, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader1, \"loadField\").mockResolvedValue(mockContext1);\n vi.spyOn(fieldLoader2, \"loadField\").mockResolvedValue(mockContext2);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader1, fieldLoader2],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN\n const result = await contextModule.getFieldContext(\n testField,\n ClearSignContextType.TOKEN,\n );\n\n // THEN\n expect(fieldLoader1.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader2.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader1.loadField).toHaveBeenCalledWith(testField);\n expect(fieldLoader2.loadField).toHaveBeenCalledWith(testField);\n expect(result).toEqual(mockContext2);\n });\n\n it(\"should handle loader rejection gracefully\", async () => {\n // GIVEN\n const fieldLoader = fieldLoaderStubBuilder();\n const loadError = new Error(\"Load field failed\");\n\n vi.spyOn(fieldLoader, \"canHandle\").mockReturnValue(true);\n vi.spyOn(fieldLoader, \"loadField\").mockRejectedValue(loadError);\n\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customFieldLoaders: [fieldLoader],\n });\n\n const testField = { type: \"error\", address: \"0x123\" };\n\n // WHEN & THEN\n await expect(\n contextModule.getFieldContext(testField, ClearSignContextType.TOKEN),\n ).rejects.toThrow(\"Load field failed\");\n\n expect(fieldLoader.canHandle).toHaveBeenCalledWith(\n testField,\n ClearSignContextType.TOKEN,\n );\n expect(fieldLoader.loadField).toHaveBeenCalledWith(testField);\n });\n });\n});\n"],
|
|
5
5
|
"mappings": "aAGA,IAAAA,EAGO,2CAGPC,EAAqC,kCAErC,MAAMC,EAA4BC,IACzB,CACL,KAAM,GAAG,GAAG,EACZ,UAAW,GACR,GAAG,EACH,gBAAgBA,CAAS,CAC9B,GAGIC,EAAyB,KACtB,CACL,UAAW,GAAG,GAAG,EACjB,UAAW,GAAG,GAAG,CACnB,GAGF,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA0C,CAAE,KAAM,GAAG,GAAG,CAAE,EAC1DC,EAAkD,CACtD,cAAe,CAAC,EAChB,eAAgB,GAChB,oBAAqB,GACrB,mBAAoB,CAAC,EACrB,sBAAuBD,EACvB,IAAK,CACH,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACA,WAAY,CACV,IAAK,uBACP,EACA,sBAAuB,CACrB,IAAK,sBACP,EACA,YAAa,aACf,EAEA,WAAW,IAAM,CACf,GAAG,gBAAgB,CACrB,CAAC,EAED,GAAG,oEAAqE,SAAY,CAGlF,MAAME,EAAM,MAFU,IAAI,uBAAqBD,CAA0B,EAEzC,YAAY,CAAC,CAAC,EAE9C,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CAAC,EAED,GAAG,+CAAgD,SAAY,CAG7D,MAAMA,EAAM,MAFU,IAAI,uBAAqBD,CAA0B,EAEzC,YAAY,CAAC,CAAC,EAE9C,OAAOC,CAAG,EAAE,QAAQ,CAAC,CAAC,CACxB,CAAC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,KAAM,QAAS,QAAS,OAAQ,EAG9CC,EAAS,MAAMJ,EAAc,gBACjCG,EACA,uBAAqB,KACvB,EAGA,OAAOG,EAAa,SAAS,EAAE,qBAC7BH,EACA,uBAAqB,KACvB,EACA,OAAOI,EAAa,SAAS,EAAE,qBAC7BJ,EACA,uBAAqB,KACvB,EACA,OAAOG,EAAa,SAAS,EAAE,qBAAqBH,CAAS,EAC7D,OAAOI,EAAa,SAAS,EAAE,qBAAqBJ,CAAS,EAC7D,OAAOC,CAAM,EAAE,QAAQK,CAAY,CACrC,CAAC,EAED,GAAG,4CAA6C,SAAY,CAE1D,MAAMP,EAAcV,EAAuB,EACrCkB,EAAY,IAAI,MAAM,mBAAmB,EAE/C,GAAG,MAAMR,EAAa,WAAW,EAAE,gBAAgB,EAAI,EACvD,GAAG,MAAMA,EAAa,WAAW,EAAE,kBAAkBQ,CAAS,EAE9D,MAAMV,EAAgB,IAAI,uBAAqB,CAC7C,GAAGN,EACH,mBAAoB,CAACQ,CAAW,CAClC,CAAC,EAEKC,EAAY,CAAE,KAAM,QAAS,QAAS,OAAQ,EAGpD,MAAM,OACJH,EAAc,gBAAgBG,EAAW,uBAAqB,KAAK,CACrE,EAAE,QAAQ,QAAQ,mBAAmB,EAErC,OAAOD,EAAY,SAAS,EAAE,qBAC5BC,EACA,uBAAqB,KACvB,EACA,OAAOD,EAAY,SAAS,EAAE,qBAAqBC,CAAS,CAC9D,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_ClearSignContext", "import_DefaultContextModule", "contextLoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
|
|
7
7
|
}
|
package/lib/cjs/src/di.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var h=(r,o)=>{for(var a in o)e(r,a,{get:o[a],enumerable:!0})},D=(r,o,a,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of N(o))!P.call(r,t)&&t!==a&&e(r,t,{get:()=>o[t],enumerable:!(m=A(o,t))||m.enumerable});return r};var L=r=>D(e({},"__esModule",{value:!0}),r);var T={};h(T,{makeContainer:()=>S});module.exports=L(T);var n=require("inversify"),i=require("./calldata/di/calldataModuleFactory"),l=require("./config/di/configModuleFactory"),c=require("./dynamic-network/di/dynamicNetworkModuleFactory"),f=require("./external-plugin/di/externalPluginModuleFactory"),p=require("./nft/di/nftModuleFactory"),d=require("./pki/di/pkiModuleFactory"),u=require("./proxy/di/proxyModuleFactory"),y=require("./safe/di/safeModuleFactory"),M=require("./solana/di/SolanaContextModuleFactory"),F=require("./solanaLifi/di/lifiModuleFactory"),s=require("./solanaToken/di/tokenModuleFactory"),C=require("./token/di/tokenModuleFactory"),k=require("./transaction-check/di/transactionCheckModuleFactory"),g=require("./trusted-name/di/trustedNameModuleFactory"),x=require("./typed-data/di/typedDataModuleFactory"),w=require("./uniswap/di/uniswapModuleFactory");const S=({config:r})=>{const o=new n.Container;return o.loadSync((0,l.configModuleFactory)(r),(0,f.externalPluginModuleFactory)(),(0,c.dynamicNetworkModuleFactory)(),(0,p.nftModuleFactory)(),(0,u.proxyModuleFactory)(r),(0,y.safeModuleFactory)(),(0,C.tokenModuleFactory)(),(0,i.calldataModuleFactory)(),(0,g.trustedNameModuleFactory)(),(0,x.typedDataModuleFactory)(),(0,d.nanoPkiModuleFactory)(),(0,w.uniswapModuleFactory)(),(0,k.transactionCheckModuleFactory)(),(0,M.solanaContextModuleFactory)(),(0,s.solanaTokenModuleFactory)(),(0,F.solanaLifiModuleFactory)()),o};0&&(module.exports={makeContainer});
|
|
2
2
|
//# sourceMappingURL=di.js.map
|
package/lib/cjs/src/di.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/di.ts"],
|
|
4
|
-
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { safeModuleFactory } from \"@/safe/di/safeModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionCheckModuleFactory } from \"@/transaction-check/di/transactionCheckModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n safeModuleFactory(),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n transactionCheckModuleFactory(),\n solanaContextModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAsC,+CACtCC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAkC,uCAClCC,EAA2C,kDAC3CC,EAAmC,yCACnCC,EAA8C,gEAC9CC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CAM9B,
|
|
6
|
-
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_calldataModuleFactory", "import_configModuleFactory", "import_dynamicNetworkModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_proxyModuleFactory", "import_safeModuleFactory", "import_SolanaContextModuleFactory", "import_tokenModuleFactory", "import_transactionCheckModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "config", "container"]
|
|
4
|
+
"sourcesContent": ["import { Container } from \"inversify\";\n\nimport { calldataModuleFactory } from \"@/calldata/di/calldataModuleFactory\";\nimport { configModuleFactory } from \"@/config/di/configModuleFactory\";\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { dynamicNetworkModuleFactory } from \"@/dynamic-network/di/dynamicNetworkModuleFactory\";\nimport { externalPluginModuleFactory } from \"@/external-plugin/di/externalPluginModuleFactory\";\nimport { nftModuleFactory } from \"@/nft/di/nftModuleFactory\";\nimport { nanoPkiModuleFactory } from \"@/pki/di/pkiModuleFactory\";\nimport { proxyModuleFactory } from \"@/proxy/di/proxyModuleFactory\";\nimport { safeModuleFactory } from \"@/safe/di/safeModuleFactory\";\nimport { solanaContextModuleFactory } from \"@/solana/di/SolanaContextModuleFactory\";\nimport { solanaLifiModuleFactory } from \"@/solanaLifi/di/lifiModuleFactory\";\nimport { solanaTokenModuleFactory } from \"@/solanaToken/di/tokenModuleFactory\";\nimport { tokenModuleFactory } from \"@/token/di/tokenModuleFactory\";\nimport { transactionCheckModuleFactory } from \"@/transaction-check/di/transactionCheckModuleFactory\";\nimport { trustedNameModuleFactory } from \"@/trusted-name/di/trustedNameModuleFactory\";\nimport { typedDataModuleFactory } from \"@/typed-data/di/typedDataModuleFactory\";\nimport { uniswapModuleFactory } from \"@/uniswap/di/uniswapModuleFactory\";\n\ntype MakeContainerArgs = {\n config: ContextModuleConfig;\n};\n\nexport const makeContainer = ({ config }: MakeContainerArgs) => {\n const container = new Container();\n\n container.loadSync(\n configModuleFactory(config),\n externalPluginModuleFactory(),\n dynamicNetworkModuleFactory(),\n nftModuleFactory(),\n proxyModuleFactory(config),\n safeModuleFactory(),\n tokenModuleFactory(),\n calldataModuleFactory(),\n trustedNameModuleFactory(),\n typedDataModuleFactory(),\n nanoPkiModuleFactory(),\n uniswapModuleFactory(),\n transactionCheckModuleFactory(),\n solanaContextModuleFactory(),\n solanaTokenModuleFactory(),\n solanaLifiModuleFactory(),\n );\n\n return container;\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0B,qBAE1BC,EAAsC,+CACtCC,EAAoC,2CAEpCC,EAA4C,4DAC5CC,EAA4C,4DAC5CC,EAAiC,qCACjCC,EAAqC,qCACrCC,EAAmC,yCACnCC,EAAkC,uCAClCC,EAA2C,kDAC3CC,EAAwC,6CACxCC,EAAyC,+CACzCA,EAAmC,yCACnCC,EAA8C,gEAC9CC,EAAyC,sDACzCC,EAAuC,kDACvCC,EAAqC,6CAM9B,MAAMjB,EAAgB,CAAC,CAAE,OAAAkB,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAI,YAEtB,OAAAA,EAAU,YACR,uBAAoBD,CAAM,KAC1B,+BAA4B,KAC5B,+BAA4B,KAC5B,oBAAiB,KACjB,sBAAmBA,CAAM,KACzB,qBAAkB,KAClB,sBAAmB,KACnB,yBAAsB,KACtB,4BAAyB,KACzB,0BAAuB,KACvB,wBAAqB,KACrB,wBAAqB,KACrB,iCAA8B,KAC9B,8BAA2B,KAC3B,4BAAyB,KACzB,2BAAwB,CAC1B,EAEOC,CACT",
|
|
6
|
+
"names": ["di_exports", "__export", "makeContainer", "__toCommonJS", "import_inversify", "import_calldataModuleFactory", "import_configModuleFactory", "import_dynamicNetworkModuleFactory", "import_externalPluginModuleFactory", "import_nftModuleFactory", "import_pkiModuleFactory", "import_proxyModuleFactory", "import_safeModuleFactory", "import_SolanaContextModuleFactory", "import_lifiModuleFactory", "import_tokenModuleFactory", "import_transactionCheckModuleFactory", "import_trustedNameModuleFactory", "import_typedDataModuleFactory", "import_uniswapModuleFactory", "config", "container"]
|
|
7
7
|
}
|
package/lib/cjs/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("./calldata/data/CalldataDescriptorDataSource"),module.exports);r(o,require("./calldata/data/HttpCalldataDescriptorDataSource"),module.exports);r(o,require("./calldata/domain/CalldataContextLoader"),module.exports);r(o,require("./config/model/ContextModuleConfig"),module.exports);r(o,require("./ContextModule"),module.exports);r(o,require("./ContextModuleBuilder"),module.exports);r(o,require("./DefaultContextModule"),module.exports);r(o,require("./dynamic-network/data/DynamicNetworkDataSource"),module.exports);r(o,require("./dynamic-network/data/HttpDynamicNetworkDataSource"),module.exports);r(o,require("./dynamic-network/domain/DynamicNetworkContextLoader"),module.exports);r(o,require("./dynamic-network/model/DynamicNetworkConfiguration"),module.exports);r(o,require("./external-plugin/data/ExternalPluginDataSource"),module.exports);r(o,require("./external-plugin/data/HttpExternalPluginDataSource"),module.exports);r(o,require("./external-plugin/domain/ExternalPluginContextLoader"),module.exports);r(o,require("./nft/data/HttpNftDataSource"),module.exports);r(o,require("./nft/data/NftDataSource"),module.exports);r(o,require("./nft/domain/NftContextFieldLoader"),module.exports);r(o,require("./nft/domain/NftContextLoader"),module.exports);r(o,require("./pki/data/HttpPkiCertificateDataSource"),module.exports);r(o,require("./pki/data/PkiCertificateDataSource"),module.exports);r(o,require("./pki/domain/DefaultPkiCertificateLoader"),module.exports);r(o,require("./pki/domain/PkiCertificateLoader"),module.exports);r(o,require("./pki/model/KeyId"),module.exports);r(o,require("./pki/model/KeyUsage"),module.exports);r(o,require("./pki/model/PkiCertificate"),module.exports);r(o,require("./pki/model/PkiCertificateInfo"),module.exports);r(o,require("./proxy/data/HttpProxyDataSource"),module.exports);r(o,require("./proxy/data/HttpSafeProxyDataSource"),module.exports);r(o,require("./proxy/data/ProxyDataSource"),module.exports);r(o,require("./proxy/domain/ProxyContextFieldLoader"),module.exports);r(o,require("./shared/domain/ContextFieldLoader"),module.exports);r(o,require("./shared/domain/ContextLoader"),module.exports);r(o,require("./shared/model/ClearSignContext"),module.exports);r(o,require("./shared/model/GenericPath"),module.exports);r(o,require("./shared/model/TransactionSubset"),module.exports);r(o,require("./shared/model/TypedDataClearSignContext"),module.exports);r(o,require("./shared/model/TypedDataContext"),module.exports);r(o,require("./solana/data/HttpSolanaOwnerInfoDataSource"),module.exports);r(o,require("./solana/data/SolanaDataSource"),module.exports);r(o,require("./solana/domain/DefaultSolanaContextLoader"),module.exports);r(o,require("./solana/domain/SolanaContextLoader"),module.exports);r(o,require("./token/data/HttpTokenDataSource"),module.exports);r(o,require("./token/data/TokenDataSource"),module.exports);r(o,require("./token/domain/TokenContextFieldLoader"),module.exports);r(o,require("./token/domain/TokenContextLoader"),module.exports);r(o,require("./trusted-name/data/HttpTrustedNameDataSource"),module.exports);r(o,require("./trusted-name/data/TrustedNameDataSource"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextFieldLoader"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextLoader"),module.exports);r(o,require("./typed-data/data/HttpTypedDataDataSource"),module.exports);r(o,require("./typed-data/data/TypedDataDataSource"),module.exports);r(o,require("./typed-data/domain/DefaultTypedDataContextLoader"),module.exports);r(o,require("./typed-data/domain/TypedDataContextLoader"),module.exports);r(o,require("./uniswap/data/AbiDecoderDataSource"),module.exports);r(o,require("./uniswap/data/CommandDecoderDataSource"),module.exports);r(o,require("./uniswap/data/DefaultCommandDecoderDataSource"),module.exports);r(o,require("./uniswap/data/EthersAbiDecoderDataSource"),module.exports);r(o,require("./uniswap/domain/UniswapContextLoader"),module.exports);0&&(module.exports={...require("./calldata/data/CalldataDescriptorDataSource"),...require("./calldata/data/HttpCalldataDescriptorDataSource"),...require("./calldata/domain/CalldataContextLoader"),...require("./config/model/ContextModuleConfig"),...require("./ContextModule"),...require("./ContextModuleBuilder"),...require("./DefaultContextModule"),...require("./dynamic-network/data/DynamicNetworkDataSource"),...require("./dynamic-network/data/HttpDynamicNetworkDataSource"),...require("./dynamic-network/domain/DynamicNetworkContextLoader"),...require("./dynamic-network/model/DynamicNetworkConfiguration"),...require("./external-plugin/data/ExternalPluginDataSource"),...require("./external-plugin/data/HttpExternalPluginDataSource"),...require("./external-plugin/domain/ExternalPluginContextLoader"),...require("./nft/data/HttpNftDataSource"),...require("./nft/data/NftDataSource"),...require("./nft/domain/NftContextFieldLoader"),...require("./nft/domain/NftContextLoader"),...require("./pki/data/HttpPkiCertificateDataSource"),...require("./pki/data/PkiCertificateDataSource"),...require("./pki/domain/DefaultPkiCertificateLoader"),...require("./pki/domain/PkiCertificateLoader"),...require("./pki/model/KeyId"),...require("./pki/model/KeyUsage"),...require("./pki/model/PkiCertificate"),...require("./pki/model/PkiCertificateInfo"),...require("./proxy/data/HttpProxyDataSource"),...require("./proxy/data/HttpSafeProxyDataSource"),...require("./proxy/data/ProxyDataSource"),...require("./proxy/domain/ProxyContextFieldLoader"),...require("./shared/domain/ContextFieldLoader"),...require("./shared/domain/ContextLoader"),...require("./shared/model/ClearSignContext"),...require("./shared/model/GenericPath"),...require("./shared/model/TransactionSubset"),...require("./shared/model/TypedDataClearSignContext"),...require("./shared/model/TypedDataContext"),...require("./solana/data/HttpSolanaOwnerInfoDataSource"),...require("./solana/data/SolanaDataSource"),...require("./solana/domain/DefaultSolanaContextLoader"),...require("./solana/domain/SolanaContextLoader"),...require("./token/data/HttpTokenDataSource"),...require("./token/data/TokenDataSource"),...require("./token/domain/TokenContextFieldLoader"),...require("./token/domain/TokenContextLoader"),...require("./trusted-name/data/HttpTrustedNameDataSource"),...require("./trusted-name/data/TrustedNameDataSource"),...require("./trusted-name/domain/TrustedNameContextFieldLoader"),...require("./trusted-name/domain/TrustedNameContextLoader"),...require("./typed-data/data/HttpTypedDataDataSource"),...require("./typed-data/data/TypedDataDataSource"),...require("./typed-data/domain/DefaultTypedDataContextLoader"),...require("./typed-data/domain/TypedDataContextLoader"),...require("./uniswap/data/AbiDecoderDataSource"),...require("./uniswap/data/CommandDecoderDataSource"),...require("./uniswap/data/DefaultCommandDecoderDataSource"),...require("./uniswap/data/EthersAbiDecoderDataSource"),...require("./uniswap/domain/UniswapContextLoader")});
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("./calldata/data/CalldataDescriptorDataSource"),module.exports);r(o,require("./calldata/data/HttpCalldataDescriptorDataSource"),module.exports);r(o,require("./calldata/domain/CalldataContextLoader"),module.exports);r(o,require("./config/model/ContextModuleConfig"),module.exports);r(o,require("./ContextModule"),module.exports);r(o,require("./ContextModuleBuilder"),module.exports);r(o,require("./DefaultContextModule"),module.exports);r(o,require("./dynamic-network/data/DynamicNetworkDataSource"),module.exports);r(o,require("./dynamic-network/data/HttpDynamicNetworkDataSource"),module.exports);r(o,require("./dynamic-network/domain/DynamicNetworkContextLoader"),module.exports);r(o,require("./dynamic-network/model/DynamicNetworkConfiguration"),module.exports);r(o,require("./external-plugin/data/ExternalPluginDataSource"),module.exports);r(o,require("./external-plugin/data/HttpExternalPluginDataSource"),module.exports);r(o,require("./external-plugin/domain/ExternalPluginContextLoader"),module.exports);r(o,require("./nft/data/HttpNftDataSource"),module.exports);r(o,require("./nft/data/NftDataSource"),module.exports);r(o,require("./nft/domain/NftContextFieldLoader"),module.exports);r(o,require("./nft/domain/NftContextLoader"),module.exports);r(o,require("./pki/data/HttpPkiCertificateDataSource"),module.exports);r(o,require("./pki/data/PkiCertificateDataSource"),module.exports);r(o,require("./pki/domain/DefaultPkiCertificateLoader"),module.exports);r(o,require("./pki/domain/PkiCertificateLoader"),module.exports);r(o,require("./pki/model/KeyId"),module.exports);r(o,require("./pki/model/KeyUsage"),module.exports);r(o,require("./pki/model/PkiCertificate"),module.exports);r(o,require("./pki/model/PkiCertificateInfo"),module.exports);r(o,require("./proxy/data/HttpProxyDataSource"),module.exports);r(o,require("./proxy/data/HttpSafeProxyDataSource"),module.exports);r(o,require("./proxy/data/ProxyDataSource"),module.exports);r(o,require("./proxy/domain/ProxyContextFieldLoader"),module.exports);r(o,require("./shared/domain/ContextFieldLoader"),module.exports);r(o,require("./shared/domain/ContextLoader"),module.exports);r(o,require("./shared/model/ClearSignContext"),module.exports);r(o,require("./shared/model/GenericPath"),module.exports);r(o,require("./shared/model/SolanaContextTypes"),module.exports);r(o,require("./shared/model/TransactionSubset"),module.exports);r(o,require("./shared/model/TypedDataClearSignContext"),module.exports);r(o,require("./shared/model/TypedDataContext"),module.exports);r(o,require("./solana/data/HttpSolanaOwnerInfoDataSource"),module.exports);r(o,require("./solana/data/SolanaDataSource"),module.exports);r(o,require("./solana/domain/DefaultSolanaContextLoader"),module.exports);r(o,require("./solana/domain/SolanaContextLoader"),module.exports);r(o,require("./solana/domain/solanaContextTypes"),module.exports);r(o,require("./token/data/HttpTokenDataSource"),module.exports);r(o,require("./token/data/TokenDataSource"),module.exports);r(o,require("./token/domain/TokenContextFieldLoader"),module.exports);r(o,require("./token/domain/TokenContextLoader"),module.exports);r(o,require("./trusted-name/data/HttpTrustedNameDataSource"),module.exports);r(o,require("./trusted-name/data/TrustedNameDataSource"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextFieldLoader"),module.exports);r(o,require("./trusted-name/domain/TrustedNameContextLoader"),module.exports);r(o,require("./typed-data/data/HttpTypedDataDataSource"),module.exports);r(o,require("./typed-data/data/TypedDataDataSource"),module.exports);r(o,require("./typed-data/domain/DefaultTypedDataContextLoader"),module.exports);r(o,require("./typed-data/domain/TypedDataContextLoader"),module.exports);r(o,require("./uniswap/data/AbiDecoderDataSource"),module.exports);r(o,require("./uniswap/data/CommandDecoderDataSource"),module.exports);r(o,require("./uniswap/data/DefaultCommandDecoderDataSource"),module.exports);r(o,require("./uniswap/data/EthersAbiDecoderDataSource"),module.exports);r(o,require("./uniswap/domain/UniswapContextLoader"),module.exports);0&&(module.exports={...require("./calldata/data/CalldataDescriptorDataSource"),...require("./calldata/data/HttpCalldataDescriptorDataSource"),...require("./calldata/domain/CalldataContextLoader"),...require("./config/model/ContextModuleConfig"),...require("./ContextModule"),...require("./ContextModuleBuilder"),...require("./DefaultContextModule"),...require("./dynamic-network/data/DynamicNetworkDataSource"),...require("./dynamic-network/data/HttpDynamicNetworkDataSource"),...require("./dynamic-network/domain/DynamicNetworkContextLoader"),...require("./dynamic-network/model/DynamicNetworkConfiguration"),...require("./external-plugin/data/ExternalPluginDataSource"),...require("./external-plugin/data/HttpExternalPluginDataSource"),...require("./external-plugin/domain/ExternalPluginContextLoader"),...require("./nft/data/HttpNftDataSource"),...require("./nft/data/NftDataSource"),...require("./nft/domain/NftContextFieldLoader"),...require("./nft/domain/NftContextLoader"),...require("./pki/data/HttpPkiCertificateDataSource"),...require("./pki/data/PkiCertificateDataSource"),...require("./pki/domain/DefaultPkiCertificateLoader"),...require("./pki/domain/PkiCertificateLoader"),...require("./pki/model/KeyId"),...require("./pki/model/KeyUsage"),...require("./pki/model/PkiCertificate"),...require("./pki/model/PkiCertificateInfo"),...require("./proxy/data/HttpProxyDataSource"),...require("./proxy/data/HttpSafeProxyDataSource"),...require("./proxy/data/ProxyDataSource"),...require("./proxy/domain/ProxyContextFieldLoader"),...require("./shared/domain/ContextFieldLoader"),...require("./shared/domain/ContextLoader"),...require("./shared/model/ClearSignContext"),...require("./shared/model/GenericPath"),...require("./shared/model/SolanaContextTypes"),...require("./shared/model/TransactionSubset"),...require("./shared/model/TypedDataClearSignContext"),...require("./shared/model/TypedDataContext"),...require("./solana/data/HttpSolanaOwnerInfoDataSource"),...require("./solana/data/SolanaDataSource"),...require("./solana/domain/DefaultSolanaContextLoader"),...require("./solana/domain/SolanaContextLoader"),...require("./solana/domain/solanaContextTypes"),...require("./token/data/HttpTokenDataSource"),...require("./token/data/TokenDataSource"),...require("./token/domain/TokenContextFieldLoader"),...require("./token/domain/TokenContextLoader"),...require("./trusted-name/data/HttpTrustedNameDataSource"),...require("./trusted-name/data/TrustedNameDataSource"),...require("./trusted-name/domain/TrustedNameContextFieldLoader"),...require("./trusted-name/domain/TrustedNameContextLoader"),...require("./typed-data/data/HttpTypedDataDataSource"),...require("./typed-data/data/TypedDataDataSource"),...require("./typed-data/domain/DefaultTypedDataContextLoader"),...require("./typed-data/domain/TypedDataContextLoader"),...require("./uniswap/data/AbiDecoderDataSource"),...require("./uniswap/data/CommandDecoderDataSource"),...require("./uniswap/data/DefaultCommandDecoderDataSource"),...require("./uniswap/data/EthersAbiDecoderDataSource"),...require("./uniswap/domain/UniswapContextLoader")});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/src/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\n"],
|
|
5
|
-
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,wDAAd,gBACAE,EAAAF,EAAc,4DADd,gBAEAE,EAAAF,EAAc,mDAFd,gBAGAE,EAAAF,EAAc,8CAHd,gBAIAE,EAAAF,EAAc,2BAJd,gBAKAE,EAAAF,EAAc,kCALd,gBAMAE,EAAAF,EAAc,kCANd,gBAOAE,EAAAF,EAAc,2DAPd,gBAQAE,EAAAF,EAAc,+DARd,gBASAE,EAAAF,EAAc,gEATd,gBAUAE,EAAAF,EAAc,+DAVd,gBAWAE,EAAAF,EAAc,2DAXd,gBAYAE,EAAAF,EAAc,+DAZd,gBAaAE,EAAAF,EAAc,gEAbd,gBAcAE,EAAAF,EAAc,wCAdd,gBAeAE,EAAAF,EAAc,oCAfd,gBAgBAE,EAAAF,EAAc,8CAhBd,gBAiBAE,EAAAF,EAAc,yCAjBd,gBAkBAE,EAAAF,EAAc,mDAlBd,gBAmBAE,EAAAF,EAAc,+CAnBd,gBAoBAE,EAAAF,EAAc,oDApBd,gBAqBAE,EAAAF,EAAc,6CArBd,gBAsBAE,EAAAF,EAAc,6BAtBd,gBAuBAE,EAAAF,EAAc,gCAvBd,gBAwBAE,EAAAF,EAAc,sCAxBd,gBAyBAE,EAAAF,EAAc,0CAzBd,gBA0BAE,EAAAF,EAAc,4CA1Bd,gBA2BAE,EAAAF,EAAc,gDA3Bd,gBA4BAE,EAAAF,EAAc,wCA5Bd,gBA6BAE,EAAAF,EAAc,kDA7Bd,gBA8BAE,EAAAF,EAAc,8CA9Bd,gBA+BAE,EAAAF,EAAc,yCA/Bd,gBAgCAE,EAAAF,EAAc,2CAhCd,gBAiCAE,EAAAF,EAAc,sCAjCd,gBAkCAE,EAAAF,EAAc,
|
|
4
|
+
"sourcesContent": ["export * from \"./calldata/data/CalldataDescriptorDataSource\";\nexport * from \"./calldata/data/HttpCalldataDescriptorDataSource\";\nexport * from \"./calldata/domain/CalldataContextLoader\";\nexport * from \"./config/model/ContextModuleConfig\";\nexport * from \"./ContextModule\";\nexport * from \"./ContextModuleBuilder\";\nexport * from \"./DefaultContextModule\";\nexport * from \"./dynamic-network/data/DynamicNetworkDataSource\";\nexport * from \"./dynamic-network/data/HttpDynamicNetworkDataSource\";\nexport * from \"./dynamic-network/domain/DynamicNetworkContextLoader\";\nexport * from \"./dynamic-network/model/DynamicNetworkConfiguration\";\nexport * from \"./external-plugin/data/ExternalPluginDataSource\";\nexport * from \"./external-plugin/data/HttpExternalPluginDataSource\";\nexport * from \"./external-plugin/domain/ExternalPluginContextLoader\";\nexport * from \"./nft/data/HttpNftDataSource\";\nexport * from \"./nft/data/NftDataSource\";\nexport * from \"./nft/domain/NftContextFieldLoader\";\nexport * from \"./nft/domain/NftContextLoader\";\nexport * from \"./pki/data/HttpPkiCertificateDataSource\";\nexport * from \"./pki/data/PkiCertificateDataSource\";\nexport * from \"./pki/domain/DefaultPkiCertificateLoader\";\nexport * from \"./pki/domain/PkiCertificateLoader\";\nexport * from \"./pki/model/KeyId\";\nexport * from \"./pki/model/KeyUsage\";\nexport * from \"./pki/model/PkiCertificate\";\nexport * from \"./pki/model/PkiCertificateInfo\";\nexport * from \"./proxy/data/HttpProxyDataSource\";\nexport * from \"./proxy/data/HttpSafeProxyDataSource\";\nexport * from \"./proxy/data/ProxyDataSource\";\nexport * from \"./proxy/domain/ProxyContextFieldLoader\";\nexport * from \"./shared/domain/ContextFieldLoader\";\nexport * from \"./shared/domain/ContextLoader\";\nexport * from \"./shared/model/ClearSignContext\";\nexport * from \"./shared/model/GenericPath\";\nexport * from \"./shared/model/SolanaContextTypes\";\nexport * from \"./shared/model/TransactionSubset\";\nexport * from \"./shared/model/TypedDataClearSignContext\";\nexport * from \"./shared/model/TypedDataContext\";\nexport * from \"./solana/data/HttpSolanaOwnerInfoDataSource\";\nexport * from \"./solana/data/SolanaDataSource\";\nexport * from \"./solana/domain/DefaultSolanaContextLoader\";\nexport * from \"./solana/domain/SolanaContextLoader\";\nexport * from \"./solana/domain/solanaContextTypes\";\nexport * from \"./token/data/HttpTokenDataSource\";\nexport * from \"./token/data/TokenDataSource\";\nexport * from \"./token/domain/TokenContextFieldLoader\";\nexport * from \"./token/domain/TokenContextLoader\";\nexport * from \"./trusted-name/data/HttpTrustedNameDataSource\";\nexport * from \"./trusted-name/data/TrustedNameDataSource\";\nexport * from \"./trusted-name/domain/TrustedNameContextFieldLoader\";\nexport * from \"./trusted-name/domain/TrustedNameContextLoader\";\nexport * from \"./typed-data/data/HttpTypedDataDataSource\";\nexport * from \"./typed-data/data/TypedDataDataSource\";\nexport * from \"./typed-data/domain/DefaultTypedDataContextLoader\";\nexport * from \"./typed-data/domain/TypedDataContextLoader\";\nexport * from \"./uniswap/data/AbiDecoderDataSource\";\nexport * from \"./uniswap/data/CommandDecoderDataSource\";\nexport * from \"./uniswap/data/DefaultCommandDecoderDataSource\";\nexport * from \"./uniswap/data/EthersAbiDecoderDataSource\";\nexport * from \"./uniswap/domain/UniswapContextLoader\";\n"],
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,wDAAd,gBACAE,EAAAF,EAAc,4DADd,gBAEAE,EAAAF,EAAc,mDAFd,gBAGAE,EAAAF,EAAc,8CAHd,gBAIAE,EAAAF,EAAc,2BAJd,gBAKAE,EAAAF,EAAc,kCALd,gBAMAE,EAAAF,EAAc,kCANd,gBAOAE,EAAAF,EAAc,2DAPd,gBAQAE,EAAAF,EAAc,+DARd,gBASAE,EAAAF,EAAc,gEATd,gBAUAE,EAAAF,EAAc,+DAVd,gBAWAE,EAAAF,EAAc,2DAXd,gBAYAE,EAAAF,EAAc,+DAZd,gBAaAE,EAAAF,EAAc,gEAbd,gBAcAE,EAAAF,EAAc,wCAdd,gBAeAE,EAAAF,EAAc,oCAfd,gBAgBAE,EAAAF,EAAc,8CAhBd,gBAiBAE,EAAAF,EAAc,yCAjBd,gBAkBAE,EAAAF,EAAc,mDAlBd,gBAmBAE,EAAAF,EAAc,+CAnBd,gBAoBAE,EAAAF,EAAc,oDApBd,gBAqBAE,EAAAF,EAAc,6CArBd,gBAsBAE,EAAAF,EAAc,6BAtBd,gBAuBAE,EAAAF,EAAc,gCAvBd,gBAwBAE,EAAAF,EAAc,sCAxBd,gBAyBAE,EAAAF,EAAc,0CAzBd,gBA0BAE,EAAAF,EAAc,4CA1Bd,gBA2BAE,EAAAF,EAAc,gDA3Bd,gBA4BAE,EAAAF,EAAc,wCA5Bd,gBA6BAE,EAAAF,EAAc,kDA7Bd,gBA8BAE,EAAAF,EAAc,8CA9Bd,gBA+BAE,EAAAF,EAAc,yCA/Bd,gBAgCAE,EAAAF,EAAc,2CAhCd,gBAiCAE,EAAAF,EAAc,sCAjCd,gBAkCAE,EAAAF,EAAc,6CAlCd,gBAmCAE,EAAAF,EAAc,4CAnCd,gBAoCAE,EAAAF,EAAc,oDApCd,gBAqCAE,EAAAF,EAAc,2CArCd,gBAsCAE,EAAAF,EAAc,uDAtCd,gBAuCAE,EAAAF,EAAc,0CAvCd,gBAwCAE,EAAAF,EAAc,sDAxCd,gBAyCAE,EAAAF,EAAc,+CAzCd,gBA0CAE,EAAAF,EAAc,8CA1Cd,gBA2CAE,EAAAF,EAAc,4CA3Cd,gBA4CAE,EAAAF,EAAc,wCA5Cd,gBA6CAE,EAAAF,EAAc,kDA7Cd,gBA8CAE,EAAAF,EAAc,6CA9Cd,gBA+CAE,EAAAF,EAAc,yDA/Cd,gBAgDAE,EAAAF,EAAc,qDAhDd,gBAiDAE,EAAAF,EAAc,+DAjDd,gBAkDAE,EAAAF,EAAc,0DAlDd,gBAmDAE,EAAAF,EAAc,qDAnDd,gBAoDAE,EAAAF,EAAc,iDApDd,gBAqDAE,EAAAF,EAAc,6DArDd,gBAsDAE,EAAAF,EAAc,sDAtDd,gBAuDAE,EAAAF,EAAc,+CAvDd,gBAwDAE,EAAAF,EAAc,mDAxDd,gBAyDAE,EAAAF,EAAc,0DAzDd,gBA0DAE,EAAAF,EAAc,qDA1Dd,gBA2DAE,EAAAF,EAAc,iDA3Dd",
|
|
6
6
|
"names": ["src_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var l=(n,e,p,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of T(e))!d.call(n,t)&&t!==p&&o(n,t,{get:()=>e[t],enumerable:!(i=r(e,t))||i.enumerable});return n};var x=n=>l(o({},"__esModule",{value:!0}),n);var C={};module.exports=x(C);
|
|
2
2
|
//# sourceMappingURL=ContextFieldLoader.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/domain/ContextFieldLoader.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport interface ContextFieldLoader
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\n/**\n * Generic context field loader that can be used for Ethereum (ClearSign),\n * Solana, or any other chain.\n *\n * - TInput: input type for the loader (field / context object)\n * - TType: enum/union of possible context types\n * - TContext: union of context objects (must have a `type` discriminator)\n */\nexport interface ContextFieldLoader<\n TInput = unknown,\n TType extends string | number = ClearSignContextType,\n TContext extends { type: string | number } = ClearSignContext,\n> {\n /**\n * @param field - The field to load\n * @returns The loaded context\n */\n loadField: (field: TInput) => Promise<TContext>;\n\n /**\n * @param field - The field to check\n * @param expectedType - The type of the context to load\n * @returns True if the loader can handle the field, false otherwise\n */\n canHandle: (field: unknown, expectedType: TType) => field is TInput;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["ContextFieldLoader_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var u=(n,t)=>{for(var c in t)i(n,c,{get:t[c],enumerable:!0})},y=(n,t,c,C)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of S(t))!T.call(n,r)&&r!==c&&i(n,r,{get:()=>t[r],enumerable:!(C=l(t,r))||C.enumerable});return n};var N=n=>y(i({},"__esModule",{value:!0}),n);var p={};u(p,{ClearSignContextReferenceType:()=>s,ClearSignContextType:()=>o});module.exports=N(p);var o=(e=>(e.TOKEN="token",e.NFT="nft",e.TRUSTED_NAME="trustedName",e.PLUGIN="plugin",e.EXTERNAL_PLUGIN="externalPlugin",e.TRANSACTION_INFO="transactionInfo",e.PROXY_INFO="proxyInfo",e.ENUM="enum",e.TRANSACTION_FIELD_DESCRIPTION="transactionFieldDescription",e.TRANSACTION_CHECK="transactionCheck",e.DYNAMIC_NETWORK="dynamicNetwork",e.DYNAMIC_NETWORK_ICON="dynamicNetworkIcon",e.ERROR="error",e.SAFE="safe",e.SIGNER="signer",e))(o||{}),s=(a=>(a.TOKEN="token",a.NFT="nft",a.TRUSTED_NAME="trustedName",a.ENUM="enum",a.CALLDATA="calldata",a))(s||{});0&&(module.exports={ClearSignContextReferenceType,ClearSignContextType});
|
|
2
2
|
//# sourceMappingURL=ClearSignContext.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/ClearSignContext.ts"],
|
|
4
|
-
"sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n PROXY_INFO = \"proxyInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n TRANSACTION_CHECK = \"transactionCheck\",\n DYNAMIC_NETWORK = \"dynamicNetwork\",\n DYNAMIC_NETWORK_ICON = \"dynamicNetworkIcon\",\n ERROR = \"error\",\n SAFE = \"safe\",\n SIGNER = \"signer\",\n}\n\nexport enum ClearSignContextReferenceType {\n TOKEN = ClearSignContextType.TOKEN,\n NFT = ClearSignContextType.NFT,\n TRUSTED_NAME = ClearSignContextType.TRUSTED_NAME,\n ENUM = ClearSignContextType.ENUM,\n CALLDATA = \"calldata\",\n}\n\
|
|
4
|
+
"sourcesContent": ["import { type PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nimport { type GenericPath } from \"./GenericPath\";\n\nexport enum ClearSignContextType {\n TOKEN = \"token\",\n NFT = \"nft\",\n TRUSTED_NAME = \"trustedName\",\n PLUGIN = \"plugin\",\n EXTERNAL_PLUGIN = \"externalPlugin\",\n TRANSACTION_INFO = \"transactionInfo\",\n PROXY_INFO = \"proxyInfo\",\n ENUM = \"enum\",\n TRANSACTION_FIELD_DESCRIPTION = \"transactionFieldDescription\",\n TRANSACTION_CHECK = \"transactionCheck\",\n DYNAMIC_NETWORK = \"dynamicNetwork\",\n DYNAMIC_NETWORK_ICON = \"dynamicNetworkIcon\",\n ERROR = \"error\",\n SAFE = \"safe\",\n SIGNER = \"signer\",\n}\n\nexport enum ClearSignContextReferenceType {\n TOKEN = ClearSignContextType.TOKEN,\n NFT = ClearSignContextType.NFT,\n TRUSTED_NAME = ClearSignContextType.TRUSTED_NAME,\n ENUM = ClearSignContextType.ENUM,\n CALLDATA = \"calldata\",\n}\n\ntype PathOnly = {\n valuePath: GenericPath;\n value?: never;\n callee?: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n};\n\ntype ValueOnly = {\n value: string;\n valuePath?: never;\n};\n\ntype PathOrValue = PathOnly | ValueOnly;\n\n// per-type payloads for references\ntype ClearSignContextReferencePayloads = {\n [ClearSignContextReferenceType.ENUM]: {\n valuePath: GenericPath;\n id: number; // enum id to reference\n };\n [ClearSignContextReferenceType.TRUSTED_NAME]: {\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n };\n [ClearSignContextReferenceType.CALLDATA]: {\n callee: GenericPath;\n valuePath: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n };\n [ClearSignContextReferenceType.TOKEN]: PathOrValue;\n [ClearSignContextReferenceType.NFT]: PathOrValue;\n};\n\n// discriminated union of all reference shapes, built from the payload map\ntype ClearSignContextReferenceUnion = {\n [T in ClearSignContextReferenceType]: {\n type: T;\n } & ClearSignContextReferencePayloads[T];\n}[ClearSignContextReferenceType];\n\nexport type ClearSignContextReference<\n T extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Extract<ClearSignContextReferenceUnion, { type: T }>;\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\n// base payload shared by most success contexts\ntype ClearSignContextSuccessBase = {\n payload: string;\n certificate?: PkiCertificate;\n};\n\n// map from ClearSign success type to payload\ntype ClearSignContextSuccessPayloadsBase = {\n [K in ClearSignContextSuccessType]: ClearSignContextSuccessBase;\n};\n\n// special cases overrides for certain context types\ntype ClearSignContextSuccessPayloadOverrides = {\n [ClearSignContextType.ENUM]: ClearSignContextSuccessBase & {\n id: number;\n value: number;\n };\n [ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION]: ClearSignContextSuccessBase & {\n reference?: ClearSignContextReference;\n };\n};\n\ntype ClearSignContextSuccessPayloads = Omit<\n ClearSignContextSuccessPayloadsBase,\n ClearSignContextType.ENUM | ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION\n> &\n ClearSignContextSuccessPayloadOverrides;\n\n// union of all success contexts, built from the payload map.\ntype ClearSignContextSuccessUnion = {\n [T in ClearSignContextSuccessType]: {\n type: T;\n } & ClearSignContextSuccessPayloads[T];\n}[ClearSignContextSuccessType];\n\nexport type ClearSignContextSuccess<\n T extends ClearSignContextSuccessType = ClearSignContextSuccessType,\n> = Extract<ClearSignContextSuccessUnion, { type: T }>;\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,EAAA,yBAAAC,IAAA,eAAAC,EAAAJ,GAIO,IAAKG,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,OAAS,SACTA,EAAA,gBAAkB,iBAClBA,EAAA,iBAAmB,kBACnBA,EAAA,WAAa,YACbA,EAAA,KAAO,OACPA,EAAA,8BAAgC,8BAChCA,EAAA,kBAAoB,mBACpBA,EAAA,gBAAkB,iBAClBA,EAAA,qBAAuB,qBACvBA,EAAA,MAAQ,QACRA,EAAA,KAAO,OACPA,EAAA,OAAS,SAfCA,OAAA,IAkBAD,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,KAAO,OACPA,EAAA,SAAW,WALDA,OAAA",
|
|
6
6
|
"names": ["ClearSignContext_exports", "__export", "ClearSignContextReferenceType", "ClearSignContextType", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var c=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},l=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of p(t))!i.call(e,a)&&a!==n&&r(e,a,{get:()=>t[a],enumerable:!(o=S(t,a))||o.enumerable});return e};var x=e=>l(r({},"__esModule",{value:!0}),e);var y={};c(y,{SolanaContextTypes:()=>s});module.exports=x(y);var s=(o=>(o.SOLANA_TOKEN="solanaToken",o.SOLANA_LIFI="solanaLifi",o.ERROR="error",o))(s||{});0&&(module.exports={SolanaContextTypes});
|
|
2
|
+
//# sourceMappingURL=SolanaContextTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/shared/model/SolanaContextTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import type { PkiCertificate } from \"@/pki/model/PkiCertificate\";\n\nexport enum SolanaContextTypes {\n SOLANA_TOKEN = \"solanaToken\",\n SOLANA_LIFI = \"solanaLifi\",\n ERROR = \"error\",\n}\n\nexport type SolanaTransactionDescriptor = {\n data: string;\n descriptorType: string;\n descriptorVersion: string;\n signatures: {\n prod?: string;\n test?: string;\n };\n};\n\nexport type SolanaTransactionDescriptorList = Record<\n string,\n SolanaTransactionDescriptor\n>;\n\nexport type SolanaTokenData = {\n solanaTokenDescriptor: {\n data: string;\n signature: string;\n };\n};\n\nexport type SolanaContextSuccessType = Exclude<\n SolanaContextTypes,\n SolanaContextTypes.ERROR\n>;\n\n// map from Solana success type to payload\ntype SolanaContextSuccessPayloads = {\n [SolanaContextTypes.SOLANA_TOKEN]: {\n payload: SolanaTokenData;\n certificate?: PkiCertificate;\n };\n [SolanaContextTypes.SOLANA_LIFI]: {\n payload: SolanaTransactionDescriptorList;\n };\n};\n\nexport type SolanaContextSuccess<\n T extends SolanaContextSuccessType = SolanaContextSuccessType,\n> = {\n type: T;\n} & SolanaContextSuccessPayloads[T];\n\nexport type SolanaContextError = {\n type: SolanaContextTypes.ERROR;\n error: Error;\n};\n\nexport type SolanaContext = SolanaContextSuccess | SolanaContextError;\n\nexport type SolanaTokenContextSuccess =\n SolanaContextSuccess<SolanaContextTypes.SOLANA_TOKEN>;\n\nexport type SolanaLifiContextSuccess =\n SolanaContextSuccess<SolanaContextTypes.SOLANA_LIFI>;\n\nexport type SolanaTokenContextResult =\n | SolanaTokenContextSuccess\n | SolanaContextError;\n\nexport type SolanaLifiContextResult =\n | SolanaLifiContextSuccess\n | SolanaContextError;\n\n// TODO LIFI\nexport type LoaderResult = SolanaTokenContextResult; //| SolanaLifiContextResult;\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAEO,IAAKE,OACVA,EAAA,aAAe,cACfA,EAAA,YAAc,aACdA,EAAA,MAAQ,QAHEA,OAAA",
|
|
6
|
+
"names": ["SolanaContextTypes_exports", "__export", "SolanaContextTypes", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var l=(t,e,s,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o(e))!a.call(t,n)&&n!==s&&r(t,n,{get:()=>e[n],enumerable:!(d=i(e,n))||d.enumerable});return t};var g=t=>l(r({},"__esModule",{value:!0}),t);var c={};module.exports=g(c);
|
|
2
2
|
//# sourceMappingURL=SolanaTransactionContext.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/model/SolanaTransactionContext.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DeviceModelId } from \"@ledgerhq/device-management-kit\";\n\nexport type SolanaTransactionContext = {\n deviceModelId: DeviceModelId;\n challenge?: string;\n tokenAddress?: string;\n createATA?: {\n address: string;\n mintAddress: string;\n };\n};\n"],
|
|
4
|
+
"sourcesContent": ["import { type DeviceModelId } from \"@ledgerhq/device-management-kit\";\n\nexport type SolanaTransactionContext = {\n deviceModelId: DeviceModelId;\n challenge?: string;\n tokenAddress?: string;\n tokenInternalId?: string;\n templateId?: string;\n createATA?: {\n address: string;\n mintAddress: string;\n };\n};\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["SolanaTransactionContext_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var A=Object.create;var d=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var M=(o,e)=>{for(var t in e)d(o,t,{get:e[t],enumerable:!0})},w=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of C(e))!x.call(o,r)&&r!==t&&d(o,r,{get:()=>e[r],enumerable:!(n=S(e,r))||n.enumerable});return o};var g=(o,e,t)=>(t=o!=null?A(D(o)):{},w(e||!o||!o.__esModule?d(t,"default",{value:o,enumerable:!0}):t,o)),v=o=>w(d({},"__esModule",{value:!0}),o),h=(o,e,t,n)=>{for(var r=n>1?void 0:n?S(e,t):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&d(e,t,r),r},E=(o,e)=>(t,n)=>e(t,n,o);var L={};M(L,{HttpSolanaOwnerInfoDataSource:()=>l});module.exports=v(L);var I=require("@ledgerhq/device-management-kit"),u=g(require("axios")),f=require("inversify"),a=require("purify-ts"),O=require("../../config/di/configTypes"),c=require("../../shared/constant/HttpHeaders"),m=g(require("../../../package.json"));let l=class{constructor(e){this.config=e;if(!this.config.originToken)throw new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required")}isSolanaSPLOwnerInfo(e){return typeof e!="object"||e===null?!1:typeof e.tokenAccount=="string"&&typeof e.owner=="string"&&typeof e.contract=="string"&&typeof e.signedDescriptor=="string"}async fetchAddressMetadata(e,t){return await u.default.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/solana/owner/${e}?challenge=${t}`,headers:{[c.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${m.default.version}`,[c.LEDGER_ORIGIN_TOKEN_HEADER]:this.config.originToken}}).then(n=>this.isSolanaSPLOwnerInfo(n.data)?(0,a.Right)(n.data):(0,a.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape"))).catch(()=>(0,a.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata")))}async computeAddressMetadata(e,t,n){return await u.default.request({method:"GET",url:`${this.config.metadataServiceDomain.url}/v2/solana/computed-token-account/${e}/${t}?challenge=${n}`,headers:{[c.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${m.default.version}`,"X-Ledger-Client-Origin":this.config.originToken}}).then(r=>this.isSolanaSPLOwnerInfo(r.data)?(0,a.Right)(r.data):(0,a.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape"))).catch(()=>(0,a.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to compute address metadata")))}async getOwnerInfo(e){const{tokenAddress:t,challenge:n,createATA:r}=e;if(!n)return(0,a.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required"));let i;if(t)i=await this.fetchAddressMetadata(t,n);else if(r?.address&&r?.mintAddress)i=await this.computeAddressMetadata(r.address,r.mintAddress,n);else return(0,a.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided"));return i.chain(s=>{const p=(0,I.hexaStringToBuffer)(s.signedDescriptor);return p?(0,a.Right)({tlvDescriptor:p}):(0,a.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 tlvDescriptor received"))})}};l=h([(0,f.injectable)(),E(0,(0,f.inject)(O.configTypes.Config))],l);0&&(module.exports={HttpSolanaOwnerInfoDataSource});
|
|
2
2
|
//# sourceMappingURL=HttpSolanaOwnerInfoDataSource.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/solana/data/HttpSolanaOwnerInfoDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import { hexaStringToBuffer } from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n SolanaSPLOwnerInfo,\n type SolanaTransactionContext,\n} from \"@/solana/domain/solanaContextTypes\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n HttpSolanaOwnerInfoDataSourceResult,\n SolanaDataSource,\n} from \"./SolanaDataSource\";\n\n@injectable()\nexport class HttpSolanaOwnerInfoDataSource implements SolanaDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {\n if (!this.config.originToken) {\n throw new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required\",\n );\n }\n }\n\n private isSolanaSPLOwnerInfo(data: {\n tokenAccount?: unknown;\n owner?: unknown;\n contract?: unknown;\n signedDescriptor?: unknown;\n }): data is SolanaSPLOwnerInfo {\n if (typeof data !== \"object\" || data === null) return false;\n return (\n typeof data.tokenAccount === \"string\" &&\n typeof data.owner === \"string\" &&\n typeof data.contract === \"string\" &&\n typeof data.signedDescriptor === \"string\"\n );\n }\n\n async fetchAddressMetadata(\n tokenAddress: string,\n challenge: string,\n ): Promise<Either<Error, SolanaSPLOwnerInfo>> {\n return await axios\n .request<SolanaSPLOwnerInfo>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/solana/owner/${tokenAddress}?challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n })\n .then((res) => {\n if (!this.isSolanaSPLOwnerInfo(res.data))\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape\",\n ),\n );\n return Right(res.data);\n })\n .catch(() =>\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata\",\n ),\n ),\n );\n }\n\n async computeAddressMetadata(\n address: string,\n mintAddress: string,\n challenge: string,\n ): Promise<Either<Error, SolanaSPLOwnerInfo>> {\n return await axios\n .request<SolanaSPLOwnerInfo>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/solana/computed-token-account/${address}/${mintAddress}?challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n \"X-Ledger-Client-Origin\": this.config.originToken,\n },\n })\n .then((res) => {\n if (!this.isSolanaSPLOwnerInfo(res.data))\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape\",\n ),\n );\n return Right(res.data);\n })\n .catch(() =>\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to compute address metadata\",\n ),\n ),\n );\n }\n\n async getOwnerInfo(\n context: SolanaTransactionContext,\n ): Promise<Either<Error, HttpSolanaOwnerInfoDataSourceResult>> {\n const { tokenAddress, challenge, createATA } = context;\n\n if (!challenge) {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required\",\n ),\n );\n }\n\n let ownerInfoResult: Either<Error, SolanaSPLOwnerInfo>;\n\n if (tokenAddress) {\n ownerInfoResult = await this.fetchAddressMetadata(\n tokenAddress,\n challenge,\n );\n } else if (createATA?.address && createATA?.mintAddress) {\n ownerInfoResult = await this.computeAddressMetadata(\n createATA.address,\n createATA.mintAddress,\n challenge,\n );\n } else {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided\",\n ),\n );\n }\n\n return ownerInfoResult.chain((ownerInfo) => {\n const
|
|
5
|
-
"mappings": "qtBAAA,IAAAA,EAAA,GAAAC,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EAAI,IAAI,KAMhC,SAAMA,EAAI,IAAI,KALZ,QACL,IAAI,MACF,gGACF,CACF,CAEH,EACA,MAAM,OACL,QACE,IAAI,MACF,qFACF,CACF,CACF,CACJ,CAEA,MAAM,aACJG,EAC6D,CAC7D,KAAM,CAAE,aAAAP,EAAc,UAAAC,EAAW,UAAAO,CAAU,EAAID,EAE/C,GAAI,CAACN,EACH,SAAO,QACL,IAAI,MACF,wEACF,CACF,EAGF,IAAIQ,EAEJ,GAAIT,EACFS,EAAkB,MAAM,KAAK,qBAC3BT,EACAC,CACF,UACSO,GAAW,SAAWA,GAAW,YAC1CC,EAAkB,MAAM,KAAK,uBAC3BD,EAAU,QACVA,EAAU,YACVP,CACF,MAEA,UAAO,QACL,IAAI,MACF,0GACF,CACF,EAGF,OAAOQ,EAAgB,MAAOC,GAAc,CAC1C,MAAMC,
|
|
6
|
-
"names": ["HttpSolanaOwnerInfoDataSource_exports", "__export", "HttpSolanaOwnerInfoDataSource", "__toCommonJS", "import_device_management_kit", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_HttpHeaders", "import_package", "HttpSolanaOwnerInfoDataSource", "config", "data", "tokenAddress", "challenge", "axios", "PACKAGE", "res", "address", "mintAddress", "context", "createATA", "ownerInfoResult", "ownerInfo", "
|
|
4
|
+
"sourcesContent": ["import { hexaStringToBuffer } from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport {\n SolanaSPLOwnerInfo,\n type SolanaTransactionContext,\n} from \"@/solana/domain/solanaContextTypes\";\nimport PACKAGE from \"@root/package.json\";\n\nimport {\n HttpSolanaOwnerInfoDataSourceResult,\n SolanaDataSource,\n} from \"./SolanaDataSource\";\n\n@injectable()\nexport class HttpSolanaOwnerInfoDataSource implements SolanaDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {\n if (!this.config.originToken) {\n throw new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required\",\n );\n }\n }\n\n private isSolanaSPLOwnerInfo(data: {\n tokenAccount?: unknown;\n owner?: unknown;\n contract?: unknown;\n signedDescriptor?: unknown;\n }): data is SolanaSPLOwnerInfo {\n if (typeof data !== \"object\" || data === null) return false;\n return (\n typeof data.tokenAccount === \"string\" &&\n typeof data.owner === \"string\" &&\n typeof data.contract === \"string\" &&\n typeof data.signedDescriptor === \"string\"\n );\n }\n\n async fetchAddressMetadata(\n tokenAddress: string,\n challenge: string,\n ): Promise<Either<Error, SolanaSPLOwnerInfo>> {\n return await axios\n .request<SolanaSPLOwnerInfo>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/solana/owner/${tokenAddress}?challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n })\n .then((res) => {\n if (!this.isSolanaSPLOwnerInfo(res.data))\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape\",\n ),\n );\n return Right(res.data);\n })\n .catch(() =>\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata\",\n ),\n ),\n );\n }\n\n async computeAddressMetadata(\n address: string,\n mintAddress: string,\n challenge: string,\n ): Promise<Either<Error, SolanaSPLOwnerInfo>> {\n return await axios\n .request<SolanaSPLOwnerInfo>({\n method: \"GET\",\n url: `${this.config.metadataServiceDomain.url}/v2/solana/computed-token-account/${address}/${mintAddress}?challenge=${challenge}`,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n \"X-Ledger-Client-Origin\": this.config.originToken,\n },\n })\n .then((res) => {\n if (!this.isSolanaSPLOwnerInfo(res.data))\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape\",\n ),\n );\n return Right(res.data);\n })\n .catch(() =>\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to compute address metadata\",\n ),\n ),\n );\n }\n\n async getOwnerInfo(\n context: SolanaTransactionContext,\n ): Promise<Either<Error, HttpSolanaOwnerInfoDataSourceResult>> {\n const { tokenAddress, challenge, createATA } = context;\n\n if (!challenge) {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required\",\n ),\n );\n }\n\n let ownerInfoResult: Either<Error, SolanaSPLOwnerInfo>;\n\n if (tokenAddress) {\n ownerInfoResult = await this.fetchAddressMetadata(\n tokenAddress,\n challenge,\n );\n } else if (createATA?.address && createATA?.mintAddress) {\n ownerInfoResult = await this.computeAddressMetadata(\n createATA.address,\n createATA.mintAddress,\n challenge,\n );\n } else {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided\",\n ),\n );\n }\n\n return ownerInfoResult.chain((ownerInfo) => {\n const tlvDescriptor = hexaStringToBuffer(ownerInfo.signedDescriptor);\n if (!tlvDescriptor) {\n return Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 tlvDescriptor received\",\n ),\n );\n }\n return Right({\n tlvDescriptor,\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "qtBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mCAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,2CACnCC,EAAkB,oBAClBC,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAGO,yCAKPC,EAAoB,iCAQb,IAAMC,EAAN,KAAgE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Ac,UAAAC,EAAW,UAAAO,CAAU,EAAID,EAE/C,GAAI,CAACN,EACH,SAAO,QACL,IAAI,MACF,wEACF,CACF,EAGF,IAAIQ,EAEJ,GAAIT,EACFS,EAAkB,MAAM,KAAK,qBAC3BT,EACAC,CACF,UACSO,GAAW,SAAWA,GAAW,YAC1CC,EAAkB,MAAM,KAAK,uBAC3BD,EAAU,QACVA,EAAU,YACVP,CACF,MAEA,UAAO,QACL,IAAI,MACF,0GACF,CACF,EAGF,OAAOQ,EAAgB,MAAOC,GAAc,CAC1C,MAAMC,KAAgB,sBAAmBD,EAAU,gBAAgB,EACnE,OAAKC,KAOE,SAAM,CACX,cAAAA,CACF,CAAC,KARQ,QACL,IAAI,MACF,wFACF,CACF,CAKJ,CAAC,CACH,CACF,EAzIad,EAANe,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,IAFjBhB",
|
|
6
|
+
"names": ["HttpSolanaOwnerInfoDataSource_exports", "__export", "HttpSolanaOwnerInfoDataSource", "__toCommonJS", "import_device_management_kit", "import_axios", "import_inversify", "import_purify_ts", "import_configTypes", "import_HttpHeaders", "import_package", "HttpSolanaOwnerInfoDataSource", "config", "data", "tokenAddress", "challenge", "axios", "PACKAGE", "res", "address", "mintAddress", "context", "createATA", "ownerInfoResult", "ownerInfo", "tlvDescriptor", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.create;var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var A=(e,a,r,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of x(a))!S.call(e,n)&&n!==r&&l(e,n,{get:()=>a[n],enumerable:!(t=w(a,n))||t.enumerable});return e};var u=(e,a,r)=>(r=e!=null?p(g(e)):{},A(a||!e||!e.__esModule?l(r,"default",{value:e,enumerable:!0}):r,e));var s=require("@ledgerhq/device-management-kit"),c=u(require("axios")),i=require("purify-ts"),
|
|
1
|
+
"use strict";var p=Object.create;var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var A=(e,a,r,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of x(a))!S.call(e,n)&&n!==r&&l(e,n,{get:()=>a[n],enumerable:!(t=w(a,n))||t.enumerable});return e};var u=(e,a,r)=>(r=e!=null?p(g(e)):{},A(a||!e||!e.__esModule?l(r,"default",{value:e,enumerable:!0}):r,e));var s=require("@ledgerhq/device-management-kit"),c=u(require("axios")),i=require("purify-ts"),f=require("../../shared/constant/HttpHeaders"),d=require("../../solana/data/HttpSolanaOwnerInfoDataSource"),m=u(require("../../../package.json"));vi.mock("axios");function h(e){const r=new TextEncoder().encode(e);return Array.from(r).map(t=>t.toString(16).padStart(2,"0")).join("")}describe("HttpSolanaOwnerInfoDataSource",()=>{const e={metadataServiceDomain:{url:"https://some.doma.in"},originToken:"mock-origin-token"},a=h("mock-descriptor"),r={tokenAccount:"token-account",owner:"owner-address",contract:"contract-address",signedDescriptor:a};beforeEach(()=>{vi.resetAllMocks()}),it("should fetch address metadata via tokenAddress",async()=>{const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0};vi.spyOn(c.default,"request").mockResolvedValueOnce({data:r});const o=await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t);expect(o.isRight()).toBe(!0),expect(o.extract()).toEqual({tlvDescriptor:(0,s.hexaStringToBuffer)(a)})}),it("should return an error if both tokenAddress and createATA are missing or invalid",async()=>{const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:void 0,challenge:"random",createATA:void 0},o=await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t);expect(o).toEqual((0,i.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided")))}),it("should return an error if challenge is missing",async()=>{const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:"some-token",challenge:void 0,createATA:void 0},o=await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t);expect(o).toEqual((0,i.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required")))}),it("should return an error if the descriptor is not valid base64",async()=>{vi.spyOn(c.default,"request").mockResolvedValueOnce({data:{...r,signedDescriptor:"!!!not-valid-base64!!!"}});const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},o=await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t);expect(o).toEqual((0,i.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 tlvDescriptor received")))}),it("should return an error if the metadata request fails",async()=>{vi.spyOn(c.default,"request").mockRejectedValueOnce(new Error("Network error"));const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},o=await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t);expect(o).toEqual((0,i.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata")))}),it("should return an error if axios request return wrong shape for fetchAddressMetadata",async()=>{vi.spyOn(c.default,"request").mockResolvedValueOnce({data:{wrong:"field"}});const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},o=await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t);expect(o).toEqual((0,i.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape")))}),it("should return an error if axios request return wrong shape for computeAddressMetadata",async()=>{vi.spyOn(c.default,"request").mockResolvedValueOnce({data:{wrong:"field"}});const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:void 0,challenge:"random",createATA:{address:"some-address",mintAddress:"some-mint"}},o=await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t);expect(o).toEqual((0,i.Left)(new Error("[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape")))}),it("should throw if originToken is missing",()=>{expect(()=>{new d.HttpSolanaOwnerInfoDataSource({...e,originToken:void 0})}).toThrow("[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required")}),it("should call axios with correct headers",async()=>{const t={deviceModelId:s.DeviceModelId.FLEX,tokenAddress:"some-token",challenge:"random",createATA:void 0},n=vi.spyOn(c.default,"request").mockResolvedValueOnce({data:r});await new d.HttpSolanaOwnerInfoDataSource(e).getOwnerInfo(t),expect(n).toHaveBeenCalledWith(expect.objectContaining({headers:{[f.LEDGER_CLIENT_VERSION_HEADER]:`context-module/${m.default.version}`,"X-Ledger-Client-Origin":e.originToken}}))})});
|
|
2
2
|
//# sourceMappingURL=HttpSolanaOwnerInfoDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/solana/data/HttpSolanaOwnerInfoDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n DeviceModelId,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport axios from \"axios\";\nimport { Left } from \"purify-ts\";\n\nimport type { ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport { LEDGER_CLIENT_VERSION_HEADER } from \"@/shared/constant/HttpHeaders\";\nimport { HttpSolanaOwnerInfoDataSource } from \"@/solana/data/HttpSolanaOwnerInfoDataSource\";\nimport type { SolanaTransactionContext } from \"@/solana/domain/solanaContextTypes\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\nfunction stringToHex(str: string): string {\n const encoder = new TextEncoder();\n const bytes = encoder.encode(str); // Uint8Array\n return Array.from(bytes)\n .map((byte) => byte.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\ndescribe(\"HttpSolanaOwnerInfoDataSource\", () => {\n const config = {\n metadataServiceDomain: { url: \"https://some.doma.in\" },\n originToken: \"mock-origin-token\",\n } as ContextModuleConfig;\n\n const signedDescriptorHex = stringToHex(\"mock-descriptor\");\n const responseData = {\n tokenAccount: \"token-account\",\n owner: \"owner-address\",\n contract: \"contract-address\",\n signedDescriptor: signedDescriptorHex,\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should fetch address metadata via tokenAddress\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result.isRight()).toBe(true);\n expect(result.extract()).toEqual({\n tlvDescriptor: hexaStringToBuffer(signedDescriptorHex),\n });\n });\n\n it(\"should return an error if both tokenAddress and createATA are missing or invalid\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: either tokenAddress or valid createATA must be provided\",\n ),\n ),\n );\n });\n\n it(\"should return an error if challenge is missing\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: undefined,\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: challenge is required\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the descriptor is not valid base64\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { ...responseData, signedDescriptor: \"!!!not-valid-base64!!!\" },\n });\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid base64 tlvDescriptor received\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the metadata request fails\", async () => {\n vi.spyOn(axios, \"request\").mockRejectedValueOnce(\n new Error(\"Network error\"),\n );\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: Failed to fetch address metadata\",\n ),\n ),\n );\n });\n\n it(\"should return an error if axios request return wrong shape for fetchAddressMetadata\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { wrong: \"field\" },\n });\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid fetchAddressMetadata response shape\",\n ),\n ),\n );\n });\n\n it(\"should return an error if axios request return wrong shape for computeAddressMetadata\", async () => {\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({\n data: { wrong: \"field\" },\n });\n\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: undefined,\n challenge: \"random\",\n createATA: {\n address: \"some-address\",\n mintAddress: \"some-mint\",\n },\n };\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n const result = await dataSource.getOwnerInfo(context);\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: invalid computeAddressMetadata response shape\",\n ),\n ),\n );\n });\n\n it(\"should throw if originToken is missing\", () => {\n expect(() => {\n new HttpSolanaOwnerInfoDataSource({\n ...config,\n originToken: undefined,\n } as any);\n }).toThrow(\n \"[ContextModule] - HttpSolanaOwnerInfoDataSource: origin token is required\",\n );\n });\n\n it(\"should call axios with correct headers\", async () => {\n const context: SolanaTransactionContext = {\n deviceModelId: DeviceModelId.FLEX,\n tokenAddress: \"some-token\",\n challenge: \"random\",\n createATA: undefined,\n };\n const spy = vi\n .spyOn(axios, \"request\")\n .mockResolvedValueOnce({ data: responseData });\n\n const dataSource = new HttpSolanaOwnerInfoDataSource(config);\n await dataSource.getOwnerInfo(context);\n\n expect(spy).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n \"X-Ledger-Client-Origin\": config.originToken,\n },\n }),\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "wdACA,IAAAA,EAGO,2CACPC,EAAkB,oBAClBC,EAAqB,qBAGrBC,EAA6C,yCAC7CC,EAA8C,uDAE9CC,EAAoB,iCAEpB,GAAG,KAAK,OAAO,EAEf,SAASC,EAAYC,EAAqB,CAExC,MAAMC,EADU,IAAI,YAAY,EACV,OAAOD,CAAG,EAChC,OAAO,MAAM,KAAKC,CAAK,EACpB,IAAKC,GAASA,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAChD,KAAK,EAAE,CACZ,CAEA,SAAS,gCAAiC,IAAM,CAC9C,MAAMC,EAAS,C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AAM,CACX,IAAI,gCAA8B,CAChC,GAAGL,EACH,YAAa,MACf,CAAQ,CACV,CAAC,EAAE,QACD,2EACF,CACF,CAAC,EAED,GAAG,yCAA0C,SAAY,CACvD,MAAMG,EAAoC,CACxC,cAAe,gBAAc,KAC7B,aAAc,aACd,UAAW,SACX,UAAW,MACb,EACMG,EAAM,GACT,MAAM,EAAAF,QAAO,SAAS,EACtB,sBAAsB,CAAE,KAAMF,CAAa,CAAC,EAG/C,MADmB,IAAI,gCAA8BF,CAAM,EAC1C,aAAaG,CAAO,EAErC,OAAOG,CAAG,EAAE,qBACV,OAAO,iBAAiB,CACtB,QAAS,CACP,CAAC,8BAA4B,EAAG,kBAAkB,EAAAC,QAAQ,OAAO,GACjE,yBAA0BP,EAAO,WACnC,CACF,CAAC,CACH,CACF,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_device_management_kit", "import_axios", "import_purify_ts", "import_HttpHeaders", "import_HttpSolanaOwnerInfoDataSource", "import_package", "stringToHex", "str", "bytes", "byte", "config", "signedDescriptorHex", "responseData", "context", "axios", "result", "spy", "PACKAGE"]
|
|
7
7
|
}
|