@ledgerhq/context-module 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/ContextModule.js +1 -1
- package/lib/cjs/src/ContextModule.js.map +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.js.map +2 -2
- package/lib/cjs/src/ContextModuleBuilder.test.js +1 -1
- package/lib/cjs/src/ContextModuleBuilder.test.js.map +2 -2
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- package/lib/cjs/src/DefaultContextModule.test.js +1 -1
- package/lib/cjs/src/DefaultContextModule.test.js.map +3 -3
- package/lib/cjs/src/config/model/ContextModuleConfig.js +1 -1
- package/lib/cjs/src/config/model/ContextModuleConfig.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/model/ClearSignContext.js +1 -1
- package/lib/cjs/src/shared/model/ClearSignContext.js.map +2 -2
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js +2 -0
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +7 -0
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +2 -0
- package/lib/cjs/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +7 -0
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js +2 -0
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +7 -0
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +2 -0
- package/lib/cjs/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +7 -0
- package/lib/cjs/src/transaction-check/data/TransactionCheckDataSource.js +2 -0
- package/lib/cjs/src/transaction-check/data/TransactionCheckDataSource.js.map +7 -0
- package/lib/cjs/src/transaction-check/data/TypedDataCheckDataSource.js +2 -0
- package/lib/cjs/src/transaction-check/data/TypedDataCheckDataSource.js.map +7 -0
- package/lib/cjs/src/transaction-check/data/dto/TransactionCheckDto.js +2 -0
- package/lib/cjs/src/transaction-check/data/dto/TransactionCheckDto.js.map +7 -0
- package/lib/cjs/src/transaction-check/data/dto/TypedDataCheckDto.js +2 -0
- package/lib/cjs/src/transaction-check/data/dto/TypedDataCheckDto.js.map +7 -0
- package/lib/cjs/src/transaction-check/di/transactionCheckModuleFactory.js +2 -0
- package/lib/cjs/src/transaction-check/di/transactionCheckModuleFactory.js.map +7 -0
- package/lib/cjs/src/transaction-check/di/transactionCheckTypes.js +2 -0
- package/lib/cjs/src/transaction-check/di/transactionCheckTypes.js.map +7 -0
- package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.js +2 -0
- package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.js.map +7 -0
- package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.test.js +2 -0
- package/lib/cjs/src/transaction-check/domain/TransactionCheckContextLoader.test.js.map +7 -0
- package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.js +2 -0
- package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.js.map +7 -0
- package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.test.js +2 -0
- package/lib/cjs/src/transaction-check/domain/TypedDataCheckContextLoader.test.js.map +7 -0
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/ContextModuleBuilder.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.js.map +2 -2
- package/lib/esm/src/ContextModuleBuilder.test.js +1 -1
- package/lib/esm/src/ContextModuleBuilder.test.js.map +2 -2
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.js.map +3 -3
- package/lib/esm/src/DefaultContextModule.test.js +1 -1
- package/lib/esm/src/DefaultContextModule.test.js.map +3 -3
- 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 +2 -2
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js +2 -0
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.js.map +7 -0
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js +2 -0
- package/lib/esm/src/transaction-check/data/HttpTransactionCheckDataSource.test.js.map +7 -0
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js +2 -0
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.js.map +7 -0
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js +2 -0
- package/lib/esm/src/transaction-check/data/HttpTypedDataCheckDataSource.test.js.map +7 -0
- package/lib/esm/src/transaction-check/data/TransactionCheckDataSource.js +1 -0
- package/lib/esm/src/transaction-check/data/TypedDataCheckDataSource.js +1 -0
- package/lib/esm/src/transaction-check/data/dto/TransactionCheckDto.js +1 -0
- package/lib/esm/src/transaction-check/data/dto/TypedDataCheckDto.js +1 -0
- package/lib/esm/src/transaction-check/di/transactionCheckModuleFactory.js +2 -0
- package/lib/esm/src/transaction-check/di/transactionCheckModuleFactory.js.map +7 -0
- package/lib/esm/src/transaction-check/di/transactionCheckTypes.js +2 -0
- package/lib/esm/src/transaction-check/di/transactionCheckTypes.js.map +7 -0
- package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.js +2 -0
- package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.js.map +7 -0
- package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.test.js +2 -0
- package/lib/esm/src/transaction-check/domain/TransactionCheckContextLoader.test.js.map +7 -0
- package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.js +2 -0
- package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.js.map +7 -0
- package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.test.js +2 -0
- package/lib/esm/src/transaction-check/domain/TypedDataCheckContextLoader.test.js.map +7 -0
- package/lib/types/src/ContextModule.d.ts +0 -2
- package/lib/types/src/ContextModule.d.ts.map +1 -1
- package/lib/types/src/ContextModuleBuilder.d.ts +0 -9
- package/lib/types/src/ContextModuleBuilder.d.ts.map +1 -1
- package/lib/types/src/DefaultContextModule.d.ts +1 -5
- package/lib/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/config/model/ContextModuleConfig.d.ts +0 -2
- package/lib/types/src/config/model/ContextModuleConfig.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +0 -5
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts +10 -0
- package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.d.ts.map +1 -0
- package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.test.d.ts +2 -0
- package/lib/types/src/transaction-check/data/HttpTransactionCheckDataSource.test.d.ts.map +1 -0
- package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts +10 -0
- package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.d.ts.map +1 -0
- package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.test.d.ts +2 -0
- package/lib/types/src/transaction-check/data/HttpTypedDataCheckDataSource.test.d.ts.map +1 -0
- package/lib/types/src/transaction-check/data/TransactionCheckDataSource.d.ts +14 -0
- package/lib/types/src/transaction-check/data/TransactionCheckDataSource.d.ts.map +1 -0
- package/lib/types/src/transaction-check/data/TypedDataCheckDataSource.d.ts +28 -0
- package/lib/types/src/transaction-check/data/TypedDataCheckDataSource.d.ts.map +1 -0
- package/lib/types/src/transaction-check/data/dto/TransactionCheckDto.d.ts +5 -0
- package/lib/types/src/transaction-check/data/dto/TransactionCheckDto.d.ts.map +1 -0
- package/lib/types/src/transaction-check/data/dto/TypedDataCheckDto.d.ts +5 -0
- package/lib/types/src/transaction-check/data/dto/TypedDataCheckDto.d.ts.map +1 -0
- package/lib/types/src/transaction-check/di/transactionCheckModuleFactory.d.ts +3 -0
- package/lib/types/src/transaction-check/di/transactionCheckModuleFactory.d.ts.map +1 -0
- package/lib/types/src/transaction-check/di/transactionCheckTypes.d.ts +7 -0
- package/lib/types/src/transaction-check/di/transactionCheckTypes.d.ts.map +1 -0
- package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.d.ts +19 -0
- package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.d.ts.map +1 -0
- package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.test.d.ts +2 -0
- package/lib/types/src/transaction-check/domain/TransactionCheckContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.d.ts +18 -0
- package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.d.ts.map +1 -0
- package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.test.d.ts +2 -0
- package/lib/types/src/transaction-check/domain/TypedDataCheckContextLoader.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js +0 -2
- package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.js.map +0 -7
- package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js +0 -2
- package/lib/cjs/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +0 -7
- package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js +0 -2
- package/lib/cjs/src/web3-check/data/Web3CheckDataSource.js.map +0 -7
- package/lib/cjs/src/web3-check/data/Web3CheckDto.js +0 -2
- package/lib/cjs/src/web3-check/data/Web3CheckDto.js.map +0 -7
- package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js +0 -2
- package/lib/cjs/src/web3-check/di/web3CheckModuleFactory.js.map +0 -7
- package/lib/cjs/src/web3-check/di/web3CheckTypes.js +0 -2
- package/lib/cjs/src/web3-check/di/web3CheckTypes.js.map +0 -7
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js +0 -2
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +0 -7
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +0 -2
- package/lib/cjs/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +0 -7
- package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js +0 -2
- package/lib/cjs/src/web3-check/domain/Web3CheckContextLoader.js.map +0 -7
- package/lib/cjs/src/web3-check/domain/web3CheckTypes.js +0 -2
- package/lib/cjs/src/web3-check/domain/web3CheckTypes.js.map +0 -7
- package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js +0 -2
- package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.js.map +0 -7
- package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js +0 -2
- package/lib/esm/src/web3-check/data/HttpWeb3CheckDataSource.test.js.map +0 -7
- package/lib/esm/src/web3-check/data/Web3CheckDataSource.js +0 -1
- package/lib/esm/src/web3-check/data/Web3CheckDto.js +0 -1
- package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js +0 -2
- package/lib/esm/src/web3-check/di/web3CheckModuleFactory.js.map +0 -7
- package/lib/esm/src/web3-check/di/web3CheckTypes.js +0 -2
- package/lib/esm/src/web3-check/di/web3CheckTypes.js.map +0 -7
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js +0 -2
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.js.map +0 -7
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js +0 -2
- package/lib/esm/src/web3-check/domain/DefaultWeb3CheckLoader.test.js.map +0 -7
- package/lib/esm/src/web3-check/domain/Web3CheckContextLoader.js +0 -1
- package/lib/esm/src/web3-check/domain/web3CheckTypes.js +0 -1
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts +0 -14
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.d.ts.map +0 -1
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts +0 -2
- package/lib/types/src/web3-check/data/HttpWeb3CheckDataSource.test.d.ts.map +0 -1
- package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts +0 -6
- package/lib/types/src/web3-check/data/Web3CheckDataSource.d.ts.map +0 -1
- package/lib/types/src/web3-check/data/Web3CheckDto.d.ts +0 -20
- package/lib/types/src/web3-check/data/Web3CheckDto.d.ts.map +0 -1
- package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts +0 -3
- package/lib/types/src/web3-check/di/web3CheckModuleFactory.d.ts.map +0 -1
- package/lib/types/src/web3-check/di/web3CheckTypes.d.ts +0 -5
- package/lib/types/src/web3-check/di/web3CheckTypes.d.ts.map +0 -1
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts +0 -10
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.d.ts.map +0 -1
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts +0 -2
- package/lib/types/src/web3-check/domain/DefaultWeb3CheckLoader.test.d.ts.map +0 -1
- package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts +0 -6
- package/lib/types/src/web3-check/domain/Web3CheckContextLoader.d.ts.map +0 -1
- package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts +0 -35
- package/lib/types/src/web3-check/domain/web3CheckTypes.d.ts.map +0 -1
- /package/lib/esm/src/{web3-check/data/Web3CheckDataSource.js.map → transaction-check/data/TransactionCheckDataSource.js.map} +0 -0
- /package/lib/esm/src/{web3-check/data/Web3CheckDto.js.map → transaction-check/data/TypedDataCheckDataSource.js.map} +0 -0
- /package/lib/esm/src/{web3-check/domain/Web3CheckContextLoader.js.map → transaction-check/data/dto/TransactionCheckDto.js.map} +0 -0
- /package/lib/esm/src/{web3-check/domain/web3CheckTypes.js.map → transaction-check/data/dto/TypedDataCheckDto.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{configTypes as s}from"./config/di/configTypes";import{ContextModuleBuilder as
|
|
1
|
+
import{configTypes as s}from"./config/di/configTypes";import{ContextModuleBuilder as a}from"./ContextModuleBuilder";import{DefaultContextModule as u}from"./DefaultContextModule";describe("ContextModuleBuilder",()=>{const i={url:"https://cal/v1",mode:"prod",branch:"main"},r={url:"https://web3checks/v1"},c={originToken:"test"};beforeEach(()=>{vi.resetAllMocks()}),it("should return a default context module",()=>{const e=new a(c).build();expect(e).toBeInstanceOf(u)}),it("should return a custom context module",()=>{const n=new a(c),e={load:vi.fn(),canHandle:vi.fn()},t=n.removeDefaultLoaders().addLoader(e).build();expect(t).toBeInstanceOf(u)}),it("should return a custom context module with a custom typed data loader",()=>{const n=new a(c),e={load:vi.fn()},t=n.removeDefaultLoaders().addTypedDataLoader(e).build();expect(t).toBeInstanceOf(u),expect(t._typedDataLoader).toBe(e)}),it("should return a custom context module with a custom config",()=>{const e=new a(c).setCalConfig(i).setWeb3ChecksConfig(r).build(),t=e._container.get(s.Config);expect(e).toBeInstanceOf(u),expect(t.cal).toEqual(i),expect(t.web3checks).toEqual(r)}),it("should not throw an error if origin token is provided",()=>{const n=new a(c);expect(()=>n.build()).not.toThrow()}),describe("setMetadataServiceConfig",()=>{it("should set the metadata service configuration",()=>{const n=new a(c),e={url:"https://custom-metadata-service.com/v3"},t=n.setMetadataServiceConfig(e).build(),o=t._container.get(s.Config);expect(t).toBeInstanceOf(u),expect(o.metadataServiceDomain).toEqual(e)}),it("should override the default metadata service configuration",()=>{const n=new a(c),e={url:"https://override-metadata-service.com/v1"},o=n.setMetadataServiceConfig(e).build()._container.get(s.Config);expect(o.metadataServiceDomain.url).toBe(e.url),expect(o.metadataServiceDomain.url).not.toBe("https://nft.api.live.ledger.com/v2")})}),describe("setCalConfig",()=>{it("should set the CAL configuration",()=>{const n=new a(c),e={url:"https://custom-cal-service.com/v2",mode:"test",branch:"next"},t=n.setCalConfig(e).build(),o=t._container.get(s.Config);expect(t).toBeInstanceOf(u),expect(o.cal).toEqual(e)}),it("should override the default CAL configuration",()=>{const n=new a(c),e={url:"https://override-cal-service.com/v1",mode:"prod",branch:"demo"},o=n.setCalConfig(e).build()._container.get(s.Config);expect(o.cal.url).toBe(e.url),expect(o.cal.mode).toBe(e.mode),expect(o.cal.branch).toBe(e.branch),expect(o.cal.url).not.toBe("https://crypto-assets-service.api.ledger.com/v1")})}),describe("setWeb3ChecksConfig",()=>{it("should set the web3 checks configuration",()=>{const n=new a(c),e={url:"https://custom-web3checks-service.com/v4"},t=n.setWeb3ChecksConfig(e).build(),o=t._container.get(s.Config);expect(t).toBeInstanceOf(u),expect(o.web3checks).toEqual(e)}),it("should override the default web3 checks configuration",()=>{const n=new a(c),e={url:"https://override-web3checks-service.com/v2"},o=n.setWeb3ChecksConfig(e).build()._container.get(s.Config);expect(o.web3checks.url).toBe(e.url),expect(o.web3checks.url).not.toBe("https://web3checks-backend.api.ledger.com/v3")})}),describe("setDatasourceConfig",()=>{it("should set the datasource configuration with safe proxy",()=>{const n=new a(c),e={proxy:"safe"},t=n.setDatasourceConfig(e).build(),o=t._container.get(s.Config);expect(t).toBeInstanceOf(u),expect(o.datasource).toEqual(e),expect(o.datasource?.proxy).toBe("safe")}),it("should set the datasource configuration with default proxy",()=>{const n=new a(c),e={proxy:"default"},t=n.setDatasourceConfig(e).build(),o=t._container.get(s.Config);expect(t).toBeInstanceOf(u),expect(o.datasource).toEqual(e),expect(o.datasource?.proxy).toBe("default")}),it("should override the default datasource configuration",()=>{const n=new a(c),e={proxy:"safe"},o=n.setDatasourceConfig(e).build()._container.get(s.Config);expect(o.datasource?.proxy).toBe("safe"),expect(o.datasource).not.toBeUndefined()}),it("should set an empty datasource configuration",()=>{const n=new a(c),e={},t=n.setDatasourceConfig(e).build(),o=t._container.get(s.Config);expect(t).toBeInstanceOf(u),expect(o.datasource).toEqual(e),expect(o.datasource?.proxy).toBeUndefined()})})});
|
|
2
2
|
//# sourceMappingURL=ContextModuleBuilder.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ContextModuleBuilder.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .setCalConfig(defaultCalConfig)\n .setWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should return a custom context module with a custom custom web3checks loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addWeb3CheckLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _web3CheckLoader is private\n expect(res[\"_web3CheckLoader\"]).toBe(customLoader);\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() => contextModuleBuilder.build()).toThrow(\n \"Origin token is required\",\n );\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n it(\"should not throw an error if origin token is not provided and addWeb3CheckLoader is called\", () => {\n const contextModuleBuilder = new ContextModuleBuilder();\n\n expect(() =>\n contextModuleBuilder.addWeb3CheckLoader({ load: vi.fn() }).build(),\n ).not.toThrow();\n });\n\n describe(\"setMetadataServiceConfig\", () => {\n it(\"should set the metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://custom-metadata-service.com/v3\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.metadataServiceDomain).toEqual(customMetadataConfig);\n });\n\n it(\"should override the default metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://override-metadata-service.com/v1\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.metadataServiceDomain.url).toBe(customMetadataConfig.url);\n expect(config.metadataServiceDomain.url).not.toBe(\n \"https://nft.api.live.ledger.com/v2\",\n );\n });\n });\n\n describe(\"setCalConfig\", () => {\n it(\"should set the CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://custom-cal-service.com/v2\",\n mode: \"test\",\n branch: \"next\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(customCalConfig);\n });\n\n it(\"should override the default CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://override-cal-service.com/v1\",\n mode: \"prod\",\n branch: \"demo\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.cal.url).toBe(customCalConfig.url);\n expect(config.cal.mode).toBe(customCalConfig.mode);\n expect(config.cal.branch).toBe(customCalConfig.branch);\n expect(config.cal.url).not.toBe(\n \"https://crypto-assets-service.api.ledger.com/v1\",\n );\n });\n });\n\n describe(\"setWeb3ChecksConfig\", () => {\n it(\"should set the web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://custom-web3checks-service.com/v4\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.web3checks).toEqual(customWeb3ChecksConfig);\n });\n\n it(\"should override the default web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://override-web3checks-service.com/v2\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.web3checks.url).toBe(customWeb3ChecksConfig.url);\n expect(config.web3checks.url).not.toBe(\n \"https://web3checks-backend.api.ledger.com/v3\",\n );\n });\n });\n\n describe(\"setDatasourceConfig\", () => {\n it(\"should set the datasource configuration with safe proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"safe\");\n });\n\n it(\"should set the datasource configuration with default proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"default\");\n });\n\n it(\"should override the default datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.datasource?.proxy).toBe(\"safe\");\n expect(config.datasource).not.toBeUndefined();\n });\n\n it(\"should set an empty datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBeUndefined();\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "AAEA,OAAS,eAAAA,MAAmB,0BAS5B,OAAS,wBAAAC,M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|
4
|
+
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport { configTypes } from \"./config/di/configTypes\";\nimport { type ContextModuleConstructorArgs } from \"./config/model/ContextModuleBuildArgs\";\nimport {\n type ContextModuleCalConfig,\n type ContextModuleConfig,\n type ContextModuleDatasourceConfig,\n type ContextModuleMetadataServiceConfig,\n} from \"./config/model/ContextModuleConfig\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport { ContextModuleBuilder } from \"./ContextModuleBuilder\";\nimport { DefaultContextModule } from \"./DefaultContextModule\";\n\ndescribe(\"ContextModuleBuilder\", () => {\n const defaultCalConfig: ContextModuleCalConfig = {\n url: \"https://cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n };\n const defaultWeb3ChecksConfig = {\n url: \"https://web3checks/v1\",\n };\n const defaultBuilderArgs: ContextModuleConstructorArgs = {\n originToken: \"test\",\n };\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n it(\"should return a default context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder.build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader: ContextLoader = {\n load: vi.fn(),\n canHandle: vi.fn() as unknown as ContextLoader[\"canHandle\"],\n };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n });\n\n it(\"should return a custom context module with a custom typed data loader\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customLoader = { load: vi.fn() };\n\n const res = contextModuleBuilder\n .removeDefaultLoaders()\n .addTypedDataLoader(customLoader)\n .build();\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n // @ts-expect-error _typedDataLoader is private\n expect(res[\"_typedDataLoader\"]).toBe(customLoader);\n });\n\n it(\"should return a custom context module with a custom config\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n const res = contextModuleBuilder\n .setCalConfig(defaultCalConfig)\n .setWeb3ChecksConfig(defaultWeb3ChecksConfig)\n .build();\n // @ts-expect-error _container is private\n const config = (res[\"_container\"] as Container).get<ContextModuleConfig>(\n configTypes.Config,\n );\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(defaultCalConfig);\n expect(config.web3checks).toEqual(defaultWeb3ChecksConfig);\n });\n\n it(\"should not throw an error if origin token is provided\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n\n expect(() => contextModuleBuilder.build()).not.toThrow();\n });\n\n describe(\"setMetadataServiceConfig\", () => {\n it(\"should set the metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://custom-metadata-service.com/v3\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.metadataServiceDomain).toEqual(customMetadataConfig);\n });\n\n it(\"should override the default metadata service configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customMetadataConfig: ContextModuleMetadataServiceConfig = {\n url: \"https://override-metadata-service.com/v1\",\n };\n\n const res = contextModuleBuilder\n .setMetadataServiceConfig(customMetadataConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.metadataServiceDomain.url).toBe(customMetadataConfig.url);\n expect(config.metadataServiceDomain.url).not.toBe(\n \"https://nft.api.live.ledger.com/v2\",\n );\n });\n });\n\n describe(\"setCalConfig\", () => {\n it(\"should set the CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://custom-cal-service.com/v2\",\n mode: \"test\",\n branch: \"next\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.cal).toEqual(customCalConfig);\n });\n\n it(\"should override the default CAL configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customCalConfig: ContextModuleCalConfig = {\n url: \"https://override-cal-service.com/v1\",\n mode: \"prod\",\n branch: \"demo\",\n };\n\n const res = contextModuleBuilder.setCalConfig(customCalConfig).build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.cal.url).toBe(customCalConfig.url);\n expect(config.cal.mode).toBe(customCalConfig.mode);\n expect(config.cal.branch).toBe(customCalConfig.branch);\n expect(config.cal.url).not.toBe(\n \"https://crypto-assets-service.api.ledger.com/v1\",\n );\n });\n });\n\n describe(\"setWeb3ChecksConfig\", () => {\n it(\"should set the web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://custom-web3checks-service.com/v4\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.web3checks).toEqual(customWeb3ChecksConfig);\n });\n\n it(\"should override the default web3 checks configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customWeb3ChecksConfig = {\n url: \"https://override-web3checks-service.com/v2\",\n };\n\n const res = contextModuleBuilder\n .setWeb3ChecksConfig(customWeb3ChecksConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.web3checks.url).toBe(customWeb3ChecksConfig.url);\n expect(config.web3checks.url).not.toBe(\n \"https://web3checks-backend.api.ledger.com/v3\",\n );\n });\n });\n\n describe(\"setDatasourceConfig\", () => {\n it(\"should set the datasource configuration with safe proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"safe\");\n });\n\n it(\"should set the datasource configuration with default proxy\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"default\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBe(\"default\");\n });\n\n it(\"should override the default datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {\n proxy: \"safe\",\n };\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(config.datasource?.proxy).toBe(\"safe\");\n expect(config.datasource).not.toBeUndefined();\n });\n\n it(\"should set an empty datasource configuration\", () => {\n const contextModuleBuilder = new ContextModuleBuilder(defaultBuilderArgs);\n const customDatasourceConfig: ContextModuleDatasourceConfig = {};\n\n const res = contextModuleBuilder\n .setDatasourceConfig(customDatasourceConfig)\n .build();\n const config = (res as DefaultContextModule)[\n \"_container\"\n ].get<ContextModuleConfig>(configTypes.Config);\n\n expect(res).toBeInstanceOf(DefaultContextModule);\n expect(config.datasource).toEqual(customDatasourceConfig);\n expect(config.datasource?.proxy).toBeUndefined();\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAEA,OAAS,eAAAA,MAAmB,0BAS5B,OAAS,wBAAAC,MAA4B,yBACrC,OAAS,wBAAAC,MAA4B,yBAErC,SAAS,uBAAwB,IAAM,CACrC,MAAMC,EAA2C,CAC/C,IAAK,iBACL,KAAM,OACN,OAAQ,MACV,EACMC,EAA0B,CAC9B,IAAK,uBACP,EACMC,EAAmD,CACvD,YAAa,MACf,EAEA,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,GAAG,yCAA0C,IAAM,CAGjD,MAAMC,EAFuB,IAAIL,EAAqBI,CAAkB,EAEvC,MAAM,EAEvC,OAAOC,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wCAAyC,IAAM,CAChD,MAAMK,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEG,EAA8B,CAClC,KAAM,GAAG,GAAG,EACZ,UAAW,GAAG,GAAG,CACnB,EAEMF,EAAMC,EACT,qBAAqB,EACrB,UAAUC,CAAY,EACtB,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeJ,CAAoB,CACjD,CAAC,EAED,GAAG,wEAAyE,IAAM,CAChF,MAAMK,EAAuB,IAAIN,EAAqBI,CAAkB,EAClEG,EAAe,CAAE,KAAM,GAAG,GAAG,CAAE,EAE/BF,EAAMC,EACT,qBAAqB,EACrB,mBAAmBC,CAAY,EAC/B,MAAM,EAET,OAAOF,CAAG,EAAE,eAAeJ,CAAoB,EAE/C,OAAOI,EAAI,gBAAmB,EAAE,KAAKE,CAAY,CACnD,CAAC,EAED,GAAG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1C,MAAM,EACHJ,EAAUH,EACd,WACA,IAAyBN,EAAY,MAAM,EAE7C,OAAOM,CAAG,EAAE,eAAeJ,CAAoB,EAC/C,OAAOO,EAAO,UAAU,EAAE,QAAQI,CAAsB,EACxD,OAAOJ,EAAO,YAAY,KAAK,EAAE,cAAc,CACjD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["configTypes", "ContextModuleBuilder", "DefaultContextModule", "defaultCalConfig", "defaultWeb3ChecksConfig", "defaultBuilderArgs", "res", "contextModuleBuilder", "customLoader", "config", "customMetadataConfig", "customCalConfig", "customWeb3ChecksConfig", "customDatasourceConfig"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as C}from"purify-ts";import{calldataTypes as
|
|
1
|
+
import{Left as C}from"purify-ts";import{calldataTypes as x}from"./calldata/di/calldataTypes";import{dynamicNetworkTypes as m}from"./dynamic-network/di/dynamicNetworkTypes";import{trustedNameTypes as i}from"./trusted-name/di/trustedNameTypes";import{externalPluginTypes as L}from"./external-plugin/di/externalPluginTypes";import{nftTypes as s}from"./nft/di/nftTypes";import{proxyTypes as y}from"./proxy/di/proxyTypes";import{safeTypes as c}from"./safe/di/safeTypes";import{ClearSignContextType as n}from"./shared/model/ClearSignContext";import{solanaContextTypes as f}from"./solana/di/solanaContextTypes";import{tokenTypes as l}from"./token/di/tokenTypes";import{transactionCheckTypes as p}from"./transaction-check/di/transactionCheckTypes";import{typedDataTypes as u}from"./typed-data/di/typedDataTypes";import{makeContainer as T}from"./di";class ${_container;_loaders;_typedDataLoader;_solanaLoader;_fieldLoaders;constructor(t){this._container=T({config:t}),this._loaders=t.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...t.customLoaders),this._fieldLoaders=t.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...t.customFieldLoaders),this._typedDataLoader=t.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._solanaLoader=t.customSolanaLoader??this._getSolanaLoader()}_getDefaultFieldLoaders(){return[this._container.get(s.NftContextFieldLoader),this._container.get(l.TokenContextFieldLoader),this._container.get(i.TrustedNameContextFieldLoader),this._container.get(y.ProxyContextFieldLoader)]}_getDefaultLoaders(){return[this._container.get(L.ExternalPluginContextLoader),this._container.get(i.TrustedNameContextLoader),this._container.get(s.NftContextLoader),this._container.get(l.TokenContextLoader),this._container.get(x.CalldataContextLoader),this._container.get(m.DynamicNetworkContextLoader),this._container.get(c.SafeAddressLoader),this._container.get(p.TransactionCheckContextLoader),this._container.get(p.TypedDataCheckContextLoader)]}_getDefaultTypedDataLoader(){return this._container.get(u.TypedDataContextLoader)}_getSolanaLoader(){try{return this._container.get(f.SolanaContextLoader)}catch{return{load:async t=>C(new Error("[ContextModule] - DefaultContextModule: no SolanaContextLoader bound"))}}}async getContexts(t,e){const o=Object.values(n),r=this._loaders.filter(d=>d.canHandle(t,e??o)).map(d=>d.load(t));return(await Promise.all(r)).flat()}async getFieldContext(t,e){const o=this._fieldLoaders.filter(a=>a.canHandle(t,e));if(o.length===0)return Promise.resolve({type:n.ERROR,error:new Error(`Loader not found for field: ${t} and expected type: ${e}`)});for(const a of o){const r=await a.loadField(t);if(r.type!==n.ERROR)return r}return{type:n.ERROR,error:new Error(`Loader not found for field: ${t} and expected type: ${e}`)}}async getTypedDataFilters(t){return this._typedDataLoader.load(t)}async getSolanaContext(t){return await this._solanaLoader.load(t)}}export{$ as DefaultContextModule};
|
|
2
2
|
//# sourceMappingURL=DefaultContextModule.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/DefaultContextModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Container } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { proxyTypes } from \"./proxy/di/proxyTypes\";\nimport { safeTypes } from \"./safe/di/safeTypes\";\nimport { type ContextFieldLoader } from \"./shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"./shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n
|
|
5
|
-
"mappings": "AACA,OAAS,QAAAA,MAAY,YAErB,OAAS,iBAAAC,MAAqB,8BAC9B,OAAS,uBAAAC,MAA2B,2CAGpC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CACpC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,aAAAC,MAAiB,sBAG1B,
|
|
6
|
-
"names": ["Left", "calldataTypes", "dynamicNetworkTypes", "trustedNameTypes", "externalPluginTypes", "nftTypes", "proxyTypes", "safeTypes", "ClearSignContextType", "solanaContextTypes", "tokenTypes", "
|
|
4
|
+
"sourcesContent": ["import { type Container } from \"inversify\";\nimport { Left } from \"purify-ts\";\n\nimport { calldataTypes } from \"@/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/dynamic-network/di/dynamicNetworkTypes\";\nimport type { TypedDataClearSignContext } from \"@/shared/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/shared/model/TypedDataContext\";\nimport { trustedNameTypes } from \"@/trusted-name/di/trustedNameTypes\";\n\nimport { type ContextModuleConfig } from \"./config/model/ContextModuleConfig\";\nimport { externalPluginTypes } from \"./external-plugin/di/externalPluginTypes\";\nimport { nftTypes } from \"./nft/di/nftTypes\";\nimport { proxyTypes } from \"./proxy/di/proxyTypes\";\nimport { safeTypes } from \"./safe/di/safeTypes\";\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 SolanaTransactionContext } from \"./shared/model/SolanaTransactionContext\";\nimport { solanaContextTypes } from \"./solana/di/solanaContextTypes\";\nimport { type SolanaContextLoader } from \"./solana/domain/SolanaContextLoader\";\nimport { type SolanaTransactionContextResult } from \"./solana/domain/solanaContextTypes\";\nimport { tokenTypes } from \"./token/di/tokenTypes\";\nimport { transactionCheckTypes } from \"./transaction-check/di/transactionCheckTypes\";\nimport { typedDataTypes } from \"./typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"./typed-data/domain/TypedDataContextLoader\";\nimport { type ContextModule } from \"./ContextModule\";\nimport { makeContainer } from \"./di\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _solanaLoader: SolanaContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n\n constructor(args: ContextModuleConfig) {\n this._container = makeContainer({ config: args });\n\n this._loaders = args.defaultLoaders ? this._getDefaultLoaders() : [];\n this._loaders.push(...args.customLoaders);\n\n this._fieldLoaders = args.defaultFieldLoaders\n ? this._getDefaultFieldLoaders()\n : [];\n this._fieldLoaders.push(...args.customFieldLoaders);\n\n this._typedDataLoader =\n args.customTypedDataLoader ?? this._getDefaultTypedDataLoader();\n this._solanaLoader = args.customSolanaLoader ?? this._getSolanaLoader();\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n tokenTypes.TokenContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n trustedNameTypes.TrustedNameContextFieldLoader,\n ),\n this._container.get<ContextFieldLoader>(\n proxyTypes.ProxyContextFieldLoader,\n ),\n ];\n }\n\n private _getDefaultLoaders(): ContextLoader<unknown>[] {\n return [\n this._container.get<ContextLoader>(\n externalPluginTypes.ExternalPluginContextLoader,\n ),\n this._container.get<ContextLoader>(\n trustedNameTypes.TrustedNameContextLoader,\n ),\n this._container.get<ContextLoader>(nftTypes.NftContextLoader),\n this._container.get<ContextLoader>(tokenTypes.TokenContextLoader),\n this._container.get<ContextLoader>(calldataTypes.CalldataContextLoader),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TypedDataCheckContextLoader,\n ),\n ];\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getSolanaLoader(): SolanaContextLoader {\n try {\n return this._container.get<SolanaContextLoader>(\n solanaContextTypes.SolanaContextLoader,\n );\n } catch {\n return {\n load: async (_ctx) =>\n Left(\n new Error(\n \"[ContextModule] - DefaultContextModule: no SolanaContextLoader bound\",\n ),\n ),\n };\n }\n }\n\n public async getContexts(\n input: unknown,\n expectedTypes?: ClearSignContextType[],\n ): Promise<ClearSignContext[]> {\n const allContextTypes = Object.values(ClearSignContextType);\n const loaders = this._loaders.filter((l) =>\n l.canHandle(input, expectedTypes ?? allContextTypes),\n );\n const promises = loaders.map((fetcher) => fetcher.load(input));\n const responses = await Promise.all(promises);\n return responses.flat();\n }\n\n public async getFieldContext<TInput>(\n field: TInput,\n expectedType: ClearSignContextType,\n ): Promise<ClearSignContext> {\n const loaders = this._fieldLoaders.filter((l) =>\n l.canHandle(field, expectedType),\n );\n if (loaders.length === 0) {\n return Promise.resolve({\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n });\n }\n\n for (const loader of loaders) {\n const context = await loader.loadField(field);\n if (context.type !== ClearSignContextType.ERROR) {\n return context;\n }\n }\n\n return {\n type: ClearSignContextType.ERROR,\n error: new Error(\n `Loader not found for field: ${field} and expected type: ${expectedType}`,\n ),\n };\n }\n\n public async getTypedDataFilters(\n typedData: TypedDataContext,\n ): Promise<TypedDataClearSignContext> {\n return this._typedDataLoader.load(typedData);\n }\n\n public async getSolanaContext(\n transactionContext: SolanaTransactionContext,\n ): Promise<SolanaTransactionContextResult> {\n return await this._solanaLoader.load(transactionContext);\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,OAAS,QAAAA,MAAY,YAErB,OAAS,iBAAAC,MAAqB,8BAC9B,OAAS,uBAAAC,MAA2B,2CAGpC,OAAS,oBAAAC,MAAwB,qCAGjC,OAAS,uBAAAC,MAA2B,2CACpC,OAAS,YAAAC,MAAgB,oBACzB,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,aAAAC,MAAiB,sBAG1B,OAEE,wBAAAC,MACK,kCAEP,OAAS,sBAAAC,MAA0B,iCAGnC,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,yBAAAC,MAA6B,+CACtC,OAAS,kBAAAC,MAAsB,iCAG/B,OAAS,iBAAAC,MAAqB,OAEvB,MAAMC,CAA8C,CACjD,WACA,SACA,iBACA,cACA,cAER,YAAYC,EAA2B,CACrC,KAAK,WAAaF,EAAc,CAAE,OAAQE,CAAK,CAAC,EAEhD,KAAK,SAAWA,EAAK,eAAiB,KAAK,mBAAmB,EAAI,CAAC,EACnE,KAAK,SAAS,KAAK,GAAGA,EAAK,aAAa,EAExC,KAAK,cAAgBA,EAAK,oBACtB,KAAK,wBAAwB,EAC7B,CAAC,EACL,KAAK,cAAc,KAAK,GAAGA,EAAK,kBAAkB,EAElD,KAAK,iBACHA,EAAK,uBAAyB,KAAK,2BAA2B,EAChE,KAAK,cAAgBA,EAAK,oBAAsB,KAAK,iB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QAAQ,QAAQ,CACrB,KAAMjB,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+Be,CAAK,uBAAuBC,CAAY,EACzE,CACF,CAAC,EAGH,UAAWE,KAAUD,EAAS,CAC5B,MAAME,EAAU,MAAMD,EAAO,UAAUH,CAAK,EAC5C,GAAII,EAAQ,OAASnB,EAAqB,MACxC,OAAOmB,CAEX,CAEA,MAAO,CACL,KAAMnB,EAAqB,MAC3B,MAAO,IAAI,MACT,+BAA+Be,CAAK,uBAAuBC,CAAY,EACzE,CACF,CACF,CAEA,MAAa,oBACXI,EACoC,CACpC,OAAO,KAAK,iBAAiB,KAAKA,CAAS,CAC7C,CAEA,MAAa,iBACXC,EACyC,CACzC,OAAO,MAAM,KAAK,cAAc,KAAKA,CAAkB,CACzD,CACF",
|
|
6
|
+
"names": ["Left", "calldataTypes", "dynamicNetworkTypes", "trustedNameTypes", "externalPluginTypes", "nftTypes", "proxyTypes", "safeTypes", "ClearSignContextType", "solanaContextTypes", "tokenTypes", "transactionCheckTypes", "typedDataTypes", "makeContainer", "DefaultContextModule", "args", "_ctx", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "transactionContext"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ClearSignContextType as o}from"./shared/model/ClearSignContext";import{DefaultContextModule as d}from"./DefaultContextModule";const u=i=>({load:vi.fn(),canHandle:vi.fn().mockReturnValue(i)}),r=()=>({canHandle:vi.fn(),loadField:vi.fn()});describe("DefaultContextModule",()=>{const i={load:vi.fn()},l={customLoaders:[],defaultLoaders:!1,defaultFieldLoaders:!1,customFieldLoaders:[],customTypedDataLoader:i,cal:{url:"https://cal/v1",mode:"prod",branch:"main"},web3checks:{url:"https://web3checks/v3"},metadataServiceDomain:{url:"https://metadata.com"},originToken:"originToken"};beforeEach(()=>{vi.restoreAllMocks()}),it("should initialize the context module with all the default loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should return an empty array when no loaders",async()=>{const t=await new d(l).getContexts({});expect(t).toEqual([])}),it("should call all fetch method from metadata fetcher",async()=>{const e=u(!0);await new d({...l,customLoaders:[e,e]}).getContexts({}),expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2)}),it("should return an array of context response",async()=>{const e=u(!0),t=[[{type:"provideERC20Info",payload:"payload1"}],[{type:"provideERC20Info",payload:"payload2"},{type:"plugin",payload:"payload3"}]];vi.spyOn(e,"load").mockResolvedValueOnce(t[0]).mockResolvedValueOnce(t[1]);const a=await new d({...l,customLoaders:[e,e]}).getContexts({});expect(e.canHandle).toHaveBeenCalledTimes(2),expect(e.load).toHaveBeenCalledTimes(2),expect(a).toEqual(t.flat())}),it("should only call loaders that can handle the input",async()=>{const e=u(!0),t=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!1),vi.spyOn(e,"load").mockResolvedValue([{type:o.TOKEN,payload:"payload1"}]),vi.spyOn(t,"load").mockResolvedValue([{type:o.NFT,payload:"payload2"}]);const n=new d({...l,customLoaders:[e,t]}),a={to:"0x123",selector:"0xabc"},s=await n.getContexts(a);expect(e.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(t.canHandle).toHaveBeenCalledWith(a,Object.values(o)),expect(e.load).toHaveBeenCalledWith(a),expect(t.load).not.toHaveBeenCalled(),expect(s).toEqual([{type:"token",payload:"payload1"}])}),it("should use expected types if provided",async()=>{const e=u(!0);vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"load").mockResolvedValue([{type:o.TOKEN,payload:"payload1"}]);const t=new d({...l,customLoaders:[e]}),n={to:"0x123",selector:"0xabc"};await t.getContexts(n,[o.TOKEN]),expect(e.canHandle).toHaveBeenCalledWith(n,[o.TOKEN])}),it("should call the typed data loader",async()=>{await new d({...l,customTypedDataLoader:i}).getTypedDataFilters({}),expect(i.load).toHaveBeenCalledTimes(1)}),describe("getFieldContext",()=>{it("should return error when no loader can handle the field",async()=>{const e=r();vi.spyOn(e,"canHandle").mockReturnValue(!1);const t=new d({...l,customFieldLoaders:[e]}),n={type:"unknown"},a=await t.getFieldContext(n,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(n,o.TOKEN),expect(e.loadField).not.toHaveBeenCalled(),expect(a).toEqual({type:o.ERROR,error:new Error(`Loader not found for field: ${n} and expected type: ${o.TOKEN}`)})}),it("should return context when a loader can handle the field",async()=>{const e=r(),t={type:o.TOKEN,payload:"test-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"token",address:"0x123"},s=await n.getFieldContext(a,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(a,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a),expect(s).toEqual(t)}),it("should return first context when multiple loaders can handle the field",async()=>{const e=r(),t=r(),n={type:o.TOKEN,payload:"first-payload"},a={type:o.NFT,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new d({...l,customFieldLoaders:[e,t]}),c={type:"multi",address:"0x123"},p=await s.getFieldContext(c,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).not.toHaveBeenCalled(),expect(p).toEqual(n)}),it("should return second context when first context is an error",async()=>{const e=r(),t=r(),n={type:o.ERROR,error:new Error("first-error")},a={type:o.TOKEN,payload:"second-payload"};vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(t,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockResolvedValue(n),vi.spyOn(t,"loadField").mockResolvedValue(a);const s=new d({...l,customFieldLoaders:[e,t]}),c={type:"error",address:"0x123"},p=await s.getFieldContext(c,o.TOKEN);expect(e.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(t.canHandle).toHaveBeenCalledWith(c,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(c),expect(t.loadField).toHaveBeenCalledWith(c),expect(p).toEqual(a)}),it("should handle loader rejection gracefully",async()=>{const e=r(),t=new Error("Load field failed");vi.spyOn(e,"canHandle").mockReturnValue(!0),vi.spyOn(e,"loadField").mockRejectedValue(t);const n=new d({...l,customFieldLoaders:[e]}),a={type:"error",address:"0x123"};await expect(n.getFieldContext(a,o.TOKEN)).rejects.toThrow("Load field failed"),expect(e.canHandle).toHaveBeenCalledWith(a,o.TOKEN),expect(e.loadField).toHaveBeenCalledWith(a)})})});
|
|
2
2
|
//# sourceMappingURL=DefaultContextModule.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/DefaultContextModule.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { DeviceModelId } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { 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 it(\"should return a web3 check context\", async () => {\n const loader = { load: vi.fn() }; // Web3CheckLoader doesn't use ContextLoader interface\n vi.spyOn(loader, \"load\").mockResolvedValueOnce(\n Right({ descriptor: \"payload\" }),\n );\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toEqual({ type: \"web3Check\", payload: \"payload\" });\n });\n\n it(\"should return null if no web3 check context\", async () => {\n const loader = { load: vi.fn() }; // Web3CheckLoader doesn't use ContextLoader interface\n vi.spyOn(loader, \"load\").mockResolvedValue(Left(new Error(\"error\")));\n const contextModule = new DefaultContextModule({\n ...defaultContextModuleConfig,\n customLoaders: [],\n customWeb3CheckLoader: loader,\n });\n\n const res = await contextModule.getWeb3Checks({\n deviceModelId: DeviceModelId.FLEX,\n from: \"from\",\n rawTx: \"rawTx\",\n chainId: 1,\n });\n\n expect(loader.load).toHaveBeenCalledTimes(1);\n expect(res).toBeNull();\n });\n\n it(\"should throw an error if origin token is not provided\", () => {\n expect(\n () =>\n new DefaultContextModule({\n ...defaultContextModuleConfig,\n originToken: undefined,\n }),\n ).toThrow(\"Origin token is required\");\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
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
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"],
|
|
5
|
+
"mappings": "AAGA,OAEE,wBAAAA,MACK,kCAGP,OAAS,wBAAAC,MAA4B,yBAErC,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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LoaderStubBuilder", "canHandle", "fieldLoaderStubBuilder", "typedDataLoader", "defaultContextModuleConfig", "res", "loader", "responses", "loader1", "loader2", "contextModule", "testInput", "fieldLoader", "testField", "result", "mockContext", "fieldLoader1", "fieldLoader2", "mockContext1", "mockContext2", "loadError"]
|
|
7
7
|
}
|
package/lib/esm/src/di.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Container as t}from"inversify";import{calldataModuleFactory as e}from"./calldata/di/calldataModuleFactory";import{configModuleFactory as a}from"./config/di/configModuleFactory";import{dynamicNetworkModuleFactory as m}from"./dynamic-network/di/dynamicNetworkModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as i}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as c}from"./pki/di/pkiModuleFactory";import{proxyModuleFactory as l}from"./proxy/di/proxyModuleFactory";import{safeModuleFactory as p}from"./safe/di/safeModuleFactory";import{solanaContextModuleFactory as d}from"./solana/di/SolanaContextModuleFactory";import{tokenModuleFactory as f}from"./token/di/tokenModuleFactory";import{
|
|
1
|
+
import{Container as t}from"inversify";import{calldataModuleFactory as e}from"./calldata/di/calldataModuleFactory";import{configModuleFactory as a}from"./config/di/configModuleFactory";import{dynamicNetworkModuleFactory as m}from"./dynamic-network/di/dynamicNetworkModuleFactory";import{externalPluginModuleFactory as n}from"./external-plugin/di/externalPluginModuleFactory";import{nftModuleFactory as i}from"./nft/di/nftModuleFactory";import{nanoPkiModuleFactory as c}from"./pki/di/pkiModuleFactory";import{proxyModuleFactory as l}from"./proxy/di/proxyModuleFactory";import{safeModuleFactory as p}from"./safe/di/safeModuleFactory";import{solanaContextModuleFactory as d}from"./solana/di/SolanaContextModuleFactory";import{tokenModuleFactory as f}from"./token/di/tokenModuleFactory";import{transactionCheckModuleFactory as u}from"./transaction-check/di/transactionCheckModuleFactory";import{trustedNameModuleFactory as y}from"./trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as M}from"./typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as F}from"./uniswap/di/uniswapModuleFactory";const v=({config:o})=>{const r=new t;return r.loadSync(a(o),n(),m(),i(),l(o),p(),f(),e(),y(),M(),c(),F(),u(),d()),r};export{v as makeContainer};
|
|
2
2
|
//# sourceMappingURL=di.js.map
|
package/lib/esm/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 {
|
|
5
|
-
"mappings": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,yBAAAC,MAA6B,sCACtC,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,8BAAAC,MAAkC,yCAC3C,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,
|
|
6
|
-
"names": ["Container", "calldataModuleFactory", "configModuleFactory", "dynamicNetworkModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "proxyModuleFactory", "safeModuleFactory", "solanaContextModuleFactory", "tokenModuleFactory", "
|
|
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": "AAAA,OAAS,aAAAA,MAAiB,YAE1B,OAAS,yBAAAC,MAA6B,sCACtC,OAAS,uBAAAC,MAA2B,kCAEpC,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,+BAAAC,MAAmC,mDAC5C,OAAS,oBAAAC,MAAwB,4BACjC,OAAS,wBAAAC,MAA4B,4BACrC,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,8BAAAC,MAAkC,yCAC3C,OAAS,sBAAAC,MAA0B,gCACnC,OAAS,iCAAAC,MAAqC,uDAC9C,OAAS,4BAAAC,MAAgC,6CACzC,OAAS,0BAAAC,MAA8B,yCACvC,OAAS,wBAAAC,MAA4B,oCAM9B,MAAMC,EAAgB,CAAC,CAAE,OAAAC,CAAO,IAAyB,CAC9D,MAAMC,EAAY,IAAIjB,EAEtB,OAAAiB,EAAU,SACRf,EAAoBc,CAAM,EAC1BZ,EAA4B,EAC5BD,EAA4B,EAC5BE,EAAiB,EACjBE,EAAmBS,CAAM,EACzBR,EAAkB,EAClBE,EAAmB,EACnBT,EAAsB,EACtBW,EAAyB,EACzBC,EAAuB,EACvBP,EAAqB,EACrBQ,EAAqB,EACrBH,EAA8B,EAC9BF,EAA2B,CAC7B,EAEOQ,CACT",
|
|
6
|
+
"names": ["Container", "calldataModuleFactory", "configModuleFactory", "dynamicNetworkModuleFactory", "externalPluginModuleFactory", "nftModuleFactory", "nanoPkiModuleFactory", "proxyModuleFactory", "safeModuleFactory", "solanaContextModuleFactory", "tokenModuleFactory", "transactionCheckModuleFactory", "trustedNameModuleFactory", "typedDataModuleFactory", "uniswapModuleFactory", "makeContainer", "config", "container"]
|
|
7
7
|
}
|
package/lib/esm/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";
|
|
1
|
+
export*from"./calldata/data/CalldataDescriptorDataSource";export*from"./calldata/data/HttpCalldataDescriptorDataSource";export*from"./calldata/domain/CalldataContextLoader";export*from"./config/model/ContextModuleConfig";export*from"./ContextModule";export*from"./ContextModuleBuilder";export*from"./DefaultContextModule";export*from"./dynamic-network/data/DynamicNetworkDataSource";export*from"./dynamic-network/data/HttpDynamicNetworkDataSource";export*from"./dynamic-network/domain/DynamicNetworkContextLoader";export*from"./dynamic-network/model/DynamicNetworkConfiguration";export*from"./external-plugin/data/ExternalPluginDataSource";export*from"./external-plugin/data/HttpExternalPluginDataSource";export*from"./external-plugin/domain/ExternalPluginContextLoader";export*from"./nft/data/HttpNftDataSource";export*from"./nft/data/NftDataSource";export*from"./nft/domain/NftContextFieldLoader";export*from"./nft/domain/NftContextLoader";export*from"./pki/data/HttpPkiCertificateDataSource";export*from"./pki/data/PkiCertificateDataSource";export*from"./pki/domain/DefaultPkiCertificateLoader";export*from"./pki/domain/PkiCertificateLoader";export*from"./pki/model/KeyId";export*from"./pki/model/KeyUsage";export*from"./pki/model/PkiCertificate";export*from"./pki/model/PkiCertificateInfo";export*from"./proxy/data/HttpProxyDataSource";export*from"./proxy/data/HttpSafeProxyDataSource";export*from"./proxy/data/ProxyDataSource";export*from"./proxy/domain/ProxyContextFieldLoader";export*from"./shared/domain/ContextFieldLoader";export*from"./shared/domain/ContextLoader";export*from"./shared/model/ClearSignContext";export*from"./shared/model/GenericPath";export*from"./shared/model/TransactionSubset";export*from"./shared/model/TypedDataClearSignContext";export*from"./shared/model/TypedDataContext";export*from"./solana/data/HttpSolanaOwnerInfoDataSource";export*from"./solana/data/SolanaDataSource";export*from"./solana/domain/DefaultSolanaContextLoader";export*from"./solana/domain/SolanaContextLoader";export*from"./token/data/HttpTokenDataSource";export*from"./token/data/TokenDataSource";export*from"./token/domain/TokenContextFieldLoader";export*from"./token/domain/TokenContextLoader";export*from"./trusted-name/data/HttpTrustedNameDataSource";export*from"./trusted-name/data/TrustedNameDataSource";export*from"./trusted-name/domain/TrustedNameContextFieldLoader";export*from"./trusted-name/domain/TrustedNameContextLoader";export*from"./typed-data/data/HttpTypedDataDataSource";export*from"./typed-data/data/TypedDataDataSource";export*from"./typed-data/domain/DefaultTypedDataContextLoader";export*from"./typed-data/domain/TypedDataContextLoader";export*from"./uniswap/data/AbiDecoderDataSource";export*from"./uniswap/data/CommandDecoderDataSource";export*from"./uniswap/data/DefaultCommandDecoderDataSource";export*from"./uniswap/data/EthersAbiDecoderDataSource";export*from"./uniswap/domain/UniswapContextLoader";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/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\";\
|
|
5
|
-
"mappings": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc
|
|
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": "AAAA,WAAc,+CACd,WAAc,mDACd,WAAc,0CACd,WAAc,qCACd,WAAc,kBACd,WAAc,yBACd,WAAc,yBACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,sDACd,WAAc,kDACd,WAAc,sDACd,WAAc,uDACd,WAAc,+BACd,WAAc,2BACd,WAAc,qCACd,WAAc,gCACd,WAAc,0CACd,WAAc,sCACd,WAAc,2CACd,WAAc,oCACd,WAAc,oBACd,WAAc,uBACd,WAAc,6BACd,WAAc,iCACd,WAAc,mCACd,WAAc,uCACd,WAAc,+BACd,WAAc,yCACd,WAAc,qCACd,WAAc,gCACd,WAAc,kCACd,WAAc,6BACd,WAAc,mCACd,WAAc,2CACd,WAAc,kCACd,WAAc,8CACd,WAAc,iCACd,WAAc,6CACd,WAAc,sCACd,WAAc,mCACd,WAAc,+BACd,WAAc,yCACd,WAAc,oCACd,WAAc,gDACd,WAAc,4CACd,WAAc,sDACd,WAAc,iDACd,WAAc,4CACd,WAAc,wCACd,WAAc,oDACd,WAAc,6CACd,WAAc,sCACd,WAAc,0CACd,WAAc,iDACd,WAAc,4CACd,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var r=(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.
|
|
1
|
+
var r=(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))(r||{}),n=(t=>(t.TOKEN="token",t.NFT="nft",t.TRUSTED_NAME="trustedName",t.ENUM="enum",t.CALLDATA="calldata",t))(n||{});export{n as ClearSignContextReferenceType,r as 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
|
|
5
|
-
"mappings": "AAIO,IAAKA,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,
|
|
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\nexport type ClearSignContextReference<\n Type extends ClearSignContextReferenceType = ClearSignContextReferenceType,\n> = Type extends ClearSignContextReferenceType.ENUM\n ? {\n type: ClearSignContextReferenceType.ENUM;\n valuePath: GenericPath;\n id: number; // enum id to reference\n }\n : Type extends ClearSignContextReferenceType.TRUSTED_NAME\n ? {\n type: ClearSignContextReferenceType.TRUSTED_NAME;\n valuePath: GenericPath;\n types: string[];\n sources: string[];\n }\n : Type extends ClearSignContextReferenceType.CALLDATA\n ? {\n type: ClearSignContextReferenceType.CALLDATA;\n callee: GenericPath;\n valuePath: GenericPath;\n selector?: GenericPath;\n amount?: GenericPath;\n spender?: GenericPath;\n chainId?: GenericPath;\n }\n :\n | {\n type: Type;\n valuePath: GenericPath;\n value?: never;\n }\n | {\n type: Type;\n valuePath?: never;\n value: string;\n };\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\nexport type ClearSignContextSuccess<\n T extends Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n > = ClearSignContextSuccessType,\n> = T extends ClearSignContextType.ENUM\n ? {\n type: ClearSignContextType.ENUM;\n id: number;\n payload: string;\n value: number;\n certificate?: PkiCertificate;\n }\n : T extends ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION\n ? {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION;\n payload: string;\n reference?: ClearSignContextReference;\n certificate?: PkiCertificate;\n }\n : {\n type: T;\n payload: string;\n certificate?: PkiCertificate;\n };\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
|
+
"mappings": "AAIO,IAAKA,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,IAkBAC,OACVA,EAAA,MAAQ,QACRA,EAAA,IAAM,MACNA,EAAA,aAAe,cACfA,EAAA,KAAO,OACPA,EAAA,SAAW,WALDA,OAAA",
|
|
6
6
|
"names": ["ClearSignContextType", "ClearSignContextReferenceType"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var s=(i,r,o,e)=>{for(var t=e>1?void 0:e?u(r,o):r,n=i.length-1,c;n>=0;n--)(c=i[n])&&(t=(e?c(r,o,t):c(t))||t);return e&&t&&m(r,o,t),t},p=(i,r)=>(o,e)=>r(o,e,i);import f from"axios";import{inject as C,injectable as k}from"inversify";import{Left as h,Right as d}from"purify-ts";import{configTypes as E}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as _,LEDGER_ORIGIN_TOKEN_HEADER as T}from"../../shared/constant/HttpHeaders";import y from"../../../package.json";let a=class{constructor(r){this.config=r}async getTransactionCheck({chainId:r,rawTx:o,from:e}){let t;const n={tx:{from:e,raw:o},chain:r};try{t=(await f.request({method:"POST",url:`${this.config.web3checks.url}/ethereum/scan/tx`,data:n,headers:{[_]:`context-module/${y.version}`,[T]:this.config.originToken}})).data}catch{return h(new Error("[ContextModule] HttpTransactionCheckDataSource: Failed to fetch web3 checks information"))}if(!this._isTransactionCheckDto(t))return h(new Error("[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received"));const c={publicKeyId:t.public_key_id,descriptor:t.descriptor};return d(c)}_isTransactionCheckDto(r){return r!=null&&typeof r=="object"&&"public_key_id"in r&&r.public_key_id!=null&&typeof r.public_key_id=="string"&&"descriptor"in r&&r.descriptor!=null&&typeof r.descriptor=="string"}};a=s([k(),p(0,C(E.Config))],a);export{a as HttpTransactionCheckDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpTransactionCheckDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/transaction-check/data/HttpTransactionCheckDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import 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 PACKAGE from \"@root/package.json\";\n\nimport { TransactionCheckDto } from \"./dto/TransactionCheckDto\";\nimport {\n GetTransactionCheckParams,\n TransactionCheck,\n} from \"./TransactionCheckDataSource\";\n\n@injectable()\nexport class HttpTransactionCheckDataSource {\n constructor(\n @inject(configTypes.Config) private readonly config: ContextModuleConfig,\n ) {}\n\n public async getTransactionCheck({\n chainId,\n rawTx,\n from,\n }: GetTransactionCheckParams): Promise<Either<Error, TransactionCheck>> {\n let transactionCheckDto: TransactionCheckDto;\n const requestDto = {\n tx: {\n from,\n raw: rawTx,\n },\n chain: chainId,\n };\n\n try {\n const response = await axios.request<TransactionCheckDto>({\n method: \"POST\",\n url: `${this.config.web3checks.url}/ethereum/scan/tx`,\n data: requestDto,\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: this.config.originToken,\n },\n });\n transactionCheckDto = response.data;\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTransactionCheckDataSource: Failed to fetch web3 checks information\",\n ),\n );\n }\n\n if (!this._isTransactionCheckDto(transactionCheckDto)) {\n return Left(\n new Error(\n \"[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received\",\n ),\n );\n }\n const result: TransactionCheck = {\n publicKeyId: transactionCheckDto.public_key_id,\n descriptor: transactionCheckDto.descriptor,\n };\n\n return Right(result);\n }\n\n private _isTransactionCheckDto(dto: unknown): dto is TransactionCheckDto {\n return (\n dto != null &&\n typeof dto == \"object\" &&\n \"public_key_id\" in dto &&\n dto.public_key_id != null &&\n typeof dto.public_key_id == \"string\" &&\n \"descriptor\" in dto &&\n dto.descriptor != null &&\n typeof dto.descriptor == \"string\"\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "iOAAA,OAAOA,MAAW,QAClB,OAAS,UAAAC,EAAQ,cAAAC,MAAkB,YACnC,OAAiB,QAAAC,EAAM,SAAAC,MAAa,YAEpC,OAAS,eAAAC,MAAmB,0BAE5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCACP,OAAOC,MAAa,qBASb,IAAMC,EAAN,KAAqC,CAC1C,YAC+CC,EAC7C,CAD6C,YAAAA,CAC5C,CAEH,MAAa,oBAAoB,CAC/B,QAAAC,EACA,MAAAC,EACA,KAAAC,CACF,EAAwE,CACtE,IAAIC,EACJ,MAAMC,EAAa,CACjB,GAAI,CACF,KAAAF,EACA,IAAKD,CACP,EACA,MAAOD,CACT,EAEA,GAAI,CAUFG,GATiB,MAAME,EAAM,QAA6B,CACxD,OAAQ,OACR,IAAK,GAAG,KAAK,OAAO,WAAW,GAAG,oBAClC,KAAMD,EACN,QAAS,CACP,CAACE,CAA4B,EAAG,kBAAkBC,EAAQ,OAAO,GACjE,CAACC,CAA0B,EAAG,KAAK,OAAO,WAC5C,CACF,CAAC,GAC8B,IACjC,MAAiB,CACf,OAAOC,EACL,IAAI,MACF,yFACF,CACF,CACF,CAEA,GAAI,CAAC,KAAK,uBAAuBN,CAAmB,EAClD,OAAOM,EACL,IAAI,MACF,gGACF,CACF,EAEF,MAAMC,EAA2B,CAC/B,YAAaP,EAAoB,cACjC,WAAYA,EAAoB,UAClC,EAEA,OAAOQ,EAAMD,CAAM,CACrB,CAEQ,uBAAuBE,EAA0C,CACvE,OACEA,GAAO,MACP,OAAOA,GAAO,UACd,kBAAmBA,GACnBA,EAAI,eAAiB,MACrB,OAAOA,EAAI,eAAiB,UAC5B,eAAgBA,GAChBA,EAAI,YAAc,MAClB,OAAOA,EAAI,YAAc,QAE7B,CACF,EAjEad,EAANe,EAAA,CADNC,EAAW,EAGPC,EAAA,EAAAC,EAAOC,EAAY,MAAM,IAFjBnB",
|
|
6
|
+
"names": ["axios", "inject", "injectable", "Left", "Right", "configTypes", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "PACKAGE", "HttpTransactionCheckDataSource", "config", "chainId", "rawTx", "from", "transactionCheckDto", "requestDto", "axios", "LEDGER_CLIENT_VERSION_HEADER", "PACKAGE", "LEDGER_ORIGIN_TOKEN_HEADER", "Left", "result", "Right", "dto", "__decorateClass", "injectable", "__decorateParam", "inject", "configTypes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import a from"axios";import{Left as s,Right as i}from"purify-ts";import{LEDGER_CLIENT_VERSION_HEADER as d,LEDGER_ORIGIN_TOKEN_HEADER as u}from"../../shared/constant/HttpHeaders";import{HttpTransactionCheckDataSource as c}from"../../transaction-check/data/HttpTransactionCheckDataSource";import h from"../../../package.json";vi.mock("axios");describe("HttpTransactionCheckDataSource",()=>{const o={web3checks:{url:"web3checksUrl"},originToken:"originToken"};beforeEach(()=>{vi.resetAllMocks()}),describe("getTransactionCheck",()=>{it("should return an object if the request is successful",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1},t={public_key_id:"test-key-id",descriptor:"test-descriptor"};vi.spyOn(a,"request").mockResolvedValueOnce({data:t});const r=await new c(o).getTransactionCheck(e);expect(r).toEqual(i({publicKeyId:"test-key-id",descriptor:"test-descriptor"}))}),it("should return an error if the request fails",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1};vi.spyOn(a,"request").mockRejectedValue(new Error("error"));const n=await new c(o).getTransactionCheck(e);expect(n).toEqual(s(new Error("[ContextModule] HttpTransactionCheckDataSource: Failed to fetch web3 checks information")))}),it("should return an error if the response is invalid",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1},t={};vi.spyOn(a,"request").mockResolvedValue({data:t});const r=await new c(o).getTransactionCheck(e);expect(r).toEqual(s(new Error("[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received")))}),it("should return an error if public_key_id is missing",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1},t={descriptor:"test-descriptor"};vi.spyOn(a,"request").mockResolvedValue({data:t});const r=await new c(o).getTransactionCheck(e);expect(r).toEqual(s(new Error("[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received")))}),it("should return an error if descriptor is missing",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1},t={public_key_id:"test-key-id"};vi.spyOn(a,"request").mockResolvedValue({data:t});const r=await new c(o).getTransactionCheck(e);expect(r).toEqual(s(new Error("[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received")))}),it("should call axios with the correct headers",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1};vi.spyOn(a,"request").mockResolvedValueOnce({data:{}}),await new c(o).getTransactionCheck(e),expect(a.request).toHaveBeenCalledWith(expect.objectContaining({headers:{[d]:`context-module/${h.version}`,[u]:o.originToken}}))}),it("should call axios with the correct URL and method",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1};vi.spyOn(a,"request").mockResolvedValueOnce({data:{}}),await new c(o).getTransactionCheck(e),expect(a.request).toHaveBeenCalledWith(expect.objectContaining({method:"POST",url:`${o.web3checks.url}/ethereum/scan/tx`}))}),it("should call axios with the correct request data",async()=>{const e={from:"0x1234567890123456789012345678901234567890",rawTx:"0xabcdef",chainId:1};vi.spyOn(a,"request").mockResolvedValueOnce({data:{}}),await new c(o).getTransactionCheck(e),expect(a.request).toHaveBeenCalledWith(expect.objectContaining({data:{tx:{from:"0x1234567890123456789012345678901234567890",raw:"0xabcdef"},chain:1}}))})})});
|
|
2
|
+
//# sourceMappingURL=HttpTransactionCheckDataSource.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/transaction-check/data/HttpTransactionCheckDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["import axios from \"axios\";\nimport { Left, Right } from \"purify-ts\";\n\nimport { type ContextModuleConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n LEDGER_CLIENT_VERSION_HEADER,\n LEDGER_ORIGIN_TOKEN_HEADER,\n} from \"@/shared/constant/HttpHeaders\";\nimport { type TransactionCheckDto } from \"@/transaction-check/data/dto/TransactionCheckDto\";\nimport { HttpTransactionCheckDataSource } from \"@/transaction-check/data/HttpTransactionCheckDataSource\";\nimport { type GetTransactionCheckParams } from \"@/transaction-check/data/TransactionCheckDataSource\";\nimport PACKAGE from \"@root/package.json\";\n\nvi.mock(\"axios\");\n\ndescribe(\"HttpTransactionCheckDataSource\", () => {\n const config = {\n web3checks: {\n url: \"web3checksUrl\",\n },\n originToken: \"originToken\",\n } as ContextModuleConfig;\n\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"getTransactionCheck\", () => {\n it(\"should return an object if the request is successful\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n const dto: TransactionCheckDto = {\n public_key_id: \"test-key-id\",\n descriptor: \"test-descriptor\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: dto });\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n const result = await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(result).toEqual(\n Right({\n publicKeyId: \"test-key-id\",\n descriptor: \"test-descriptor\",\n }),\n );\n });\n\n it(\"should return an error if the request fails\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n vi.spyOn(axios, \"request\").mockRejectedValue(new Error(\"error\"));\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n const result = await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionCheckDataSource: Failed to fetch web3 checks information\",\n ),\n ),\n );\n });\n\n it(\"should return an error if the response is invalid\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n const dto = {};\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: dto });\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n const result = await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received\",\n ),\n ),\n );\n });\n\n it(\"should return an error if public_key_id is missing\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n const dto = {\n descriptor: \"test-descriptor\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: dto });\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n const result = await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received\",\n ),\n ),\n );\n });\n\n it(\"should return an error if descriptor is missing\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n const dto = {\n public_key_id: \"test-key-id\",\n };\n vi.spyOn(axios, \"request\").mockResolvedValue({ data: dto });\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n const result = await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTransactionCheckDataSource: Cannot exploit transaction check data received\",\n ),\n ),\n );\n });\n\n it(\"should call axios with the correct headers\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: {} });\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n headers: {\n [LEDGER_CLIENT_VERSION_HEADER]: `context-module/${PACKAGE.version}`,\n [LEDGER_ORIGIN_TOKEN_HEADER]: config.originToken,\n },\n }),\n );\n });\n\n it(\"should call axios with the correct URL and method\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: {} });\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n method: \"POST\",\n url: `${config.web3checks.url}/ethereum/scan/tx`,\n }),\n );\n });\n\n it(\"should call axios with the correct request data\", async () => {\n // GIVEN\n const params: GetTransactionCheckParams = {\n from: \"0x1234567890123456789012345678901234567890\",\n rawTx: \"0xabcdef\",\n chainId: 1,\n };\n vi.spyOn(axios, \"request\").mockResolvedValueOnce({ data: {} });\n\n // WHEN\n const dataSource = new HttpTransactionCheckDataSource(config);\n await dataSource.getTransactionCheck(params);\n\n // THEN\n expect(axios.request).toHaveBeenCalledWith(\n expect.objectContaining({\n data: {\n tx: {\n from: \"0x1234567890123456789012345678901234567890\",\n raw: \"0xabcdef\",\n },\n chain: 1,\n },\n }),\n );\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAW,QAClB,OAAS,QAAAC,EAAM,SAAAC,MAAa,YAG5B,OACE,gCAAAC,EACA,8BAAAC,MACK,gCAEP,OAAS,kCAAAC,MAAsC,0DAE/C,OAAOC,MAAa,qBAEpB,GAAG,KAAK,OAAO,EAEf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B,OAAQ,OACR,IAAK,GAAGO,EAAO,WAAW,GAAG,mBAC/B,CAAC,CACH,CACF,CAAC,EAED,GAAG,kDAAmD,SAAY,CAEhE,MAAMC,EAAoC,CACxC,KAAM,6CACN,MAAO,WACP,QAAS,CACX,EACA,GAAG,MAAMR,EAAO,SAAS,EAAE,sBAAsB,CAAE,KAAM,CAAC,CAAE,CAAC,EAI7D,MADmB,IAAIK,EAA+BE,CAAM,EAC3C,oBAAoBC,CAAM,EAG3C,OAAOR,EAAM,OAAO,EAAE,qBACpB,OAAO,iBAAiB,CACtB,KAAM,CACJ,GAAI,CACF,KAAM,6CACN,IAAK,UACP,EACA,MAAO,CACT,CACF,CAAC,CACH,CACF,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["axios", "Left", "Right", "LEDGER_CLIENT_VERSION_HEADER", "LEDGER_ORIGIN_TOKEN_HEADER", "HttpTransactionCheckDataSource", "PACKAGE", "config", "params", "dto", "result"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var y=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var n=(i,e,o,t)=>{for(var r=t>1?void 0:t?h(e,o):e,a=i.length-1,c;a>=0;a--)(c=i[a])&&(r=(t?c(e,o,r):c(r))||r);return t&&r&&y(e,o,r),r},s=(i,e)=>(o,t)=>e(o,t,i);import m from"axios";import{inject as l,injectable as u}from"inversify";import{Left as d,Right as D}from"purify-ts";import{configTypes as C}from"../../config/di/configTypes";import{LEDGER_CLIENT_VERSION_HEADER as f,LEDGER_ORIGIN_TOKEN_HEADER as k}from"../../shared/constant/HttpHeaders";import T from"../../../package.json";let p=class{constructor(e){this.config=e}async getTypedDataCheck({from:e,data:o}){let t;const r={msg:{from:e,data:o}};try{t=(await m.request({method:"POST",url:`${this.config.web3checks.url}/ethereum/scan/eip-712`,data:r,headers:{[f]:`context-module/${T.version}`,[k]:this.config.originToken}})).data}catch{return d(new Error("[ContextModule] HttpTypedDataCheckDataSource: Failed to fetch typed data check information"))}if(!this._isTypedDataCheckDto(t))return d(new Error("[ContextModule] HttpTypedDataCheckDataSource: Cannot exploit typed data check data received"));const a={publicKeyId:t.public_key_id,descriptor:t.descriptor};return D(a)}_isTypedDataCheckDto(e){return e!=null&&typeof e=="object"&&"public_key_id"in e&&e.public_key_id!=null&&typeof e.public_key_id=="string"&&"descriptor"in e&&e.descriptor!=null&&typeof e.descriptor=="string"}};p=n([u(),s(0,l(C.Config))],p);export{p as HttpTypedDataCheckDataSource};
|
|
2
|
+
//# sourceMappingURL=HttpTypedDataCheckDataSource.js.map
|