@ledgerhq/context-module 2.5.0 → 2.6.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 +2 -2
- package/lib/cjs/src/DefaultContextModule.js +1 -1
- package/lib/cjs/src/DefaultContextModule.js.map +3 -3
- 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/modules/multichain/reporter/model/BlindSigningEvent.js +1 -1
- package/lib/cjs/src/modules/multichain/reporter/model/BlindSigningEvent.js.map +2 -2
- package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +2 -2
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js.map +2 -2
- package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js +1 -1
- package/lib/cjs/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js.map +2 -2
- package/lib/cjs/src/modules/solana/model/SolanaClearSignContext.js +1 -1
- package/lib/cjs/src/modules/solana/model/SolanaClearSignContext.js.map +2 -2
- package/lib/cjs/src/modules/solana/model/SolanaPayloads.js +1 -1
- package/lib/cjs/src/modules/solana/model/SolanaPayloads.js.map +2 -2
- package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js +1 -1
- package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map +3 -3
- package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.test.js +1 -1
- package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.test.js.map +3 -3
- package/lib/cjs/src/modules/tron/model/TronTransactionContext.js +2 -0
- package/lib/cjs/src/modules/tron/model/TronTransactionContext.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/data/HttpTokenDataSource.js +2 -0
- package/lib/cjs/src/modules/tron/token/data/HttpTokenDataSource.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/data/HttpTokenDataSource.test.js +2 -0
- package/lib/cjs/src/modules/tron/token/data/HttpTokenDataSource.test.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/data/TokenDataSource.js +2 -0
- package/lib/cjs/src/modules/tron/token/data/TokenDataSource.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/di/tokenModuleFactory.js +2 -0
- package/lib/cjs/src/modules/tron/token/di/tokenModuleFactory.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/di/tokenTypes.js +2 -0
- package/lib/cjs/src/modules/tron/token/di/tokenTypes.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/domain/TokenContextLoader.js +2 -0
- package/lib/cjs/src/modules/tron/token/domain/TokenContextLoader.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/domain/TokenContextLoader.test.js +2 -0
- package/lib/cjs/src/modules/tron/token/domain/TokenContextLoader.test.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/domain/parseTrc10AssetId.js +2 -0
- package/lib/cjs/src/modules/tron/token/domain/parseTrc10AssetId.js.map +7 -0
- package/lib/cjs/src/modules/tron/token/domain/parseTrc10AssetId.test.js +2 -0
- package/lib/cjs/src/modules/tron/token/domain/parseTrc10AssetId.test.js.map +7 -0
- package/lib/cjs/src/shared/domain/ContextModuleChainID.js +1 -1
- package/lib/cjs/src/shared/domain/ContextModuleChainID.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/esm/package.json +2 -2
- package/lib/esm/src/DefaultContextModule.js +1 -1
- package/lib/esm/src/DefaultContextModule.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/modules/multichain/reporter/model/BlindSigningEvent.js +1 -1
- package/lib/esm/src/modules/multichain/reporter/model/BlindSigningEvent.js.map +2 -2
- package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/HttpInstructionInfoDataSource.test.js.map +2 -2
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoDto.js.map +3 -3
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.js.map +3 -3
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/data/InstructionInfoMapper.test.js.map +3 -3
- package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js +1 -1
- package/lib/esm/src/modules/solana/instruction-info/domain/InstructionInfoContextLoader.test.js.map +2 -2
- package/lib/esm/src/modules/solana/model/SolanaClearSignContext.js +1 -1
- package/lib/esm/src/modules/solana/model/SolanaClearSignContext.js.map +2 -2
- package/lib/esm/src/modules/solana/model/SolanaPayloads.js.map +2 -2
- package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js +1 -1
- package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map +3 -3
- package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.test.js +1 -1
- package/lib/esm/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.test.js.map +3 -3
- package/lib/esm/src/modules/tron/model/TronTransactionContext.js +1 -0
- package/lib/esm/src/modules/tron/model/TronTransactionContext.js.map +7 -0
- package/lib/esm/src/modules/tron/token/data/HttpTokenDataSource.js +2 -0
- package/lib/esm/src/modules/tron/token/data/HttpTokenDataSource.js.map +7 -0
- package/lib/esm/src/modules/tron/token/data/HttpTokenDataSource.test.js +2 -0
- package/lib/esm/src/modules/tron/token/data/HttpTokenDataSource.test.js.map +7 -0
- package/lib/esm/src/modules/tron/token/data/TokenDataSource.js +2 -0
- package/lib/esm/src/modules/tron/token/data/TokenDataSource.js.map +7 -0
- package/lib/esm/src/modules/tron/token/di/tokenModuleFactory.js +2 -0
- package/lib/esm/src/modules/tron/token/di/tokenModuleFactory.js.map +7 -0
- package/lib/esm/src/modules/tron/token/di/tokenTypes.js +2 -0
- package/lib/esm/src/modules/tron/token/di/tokenTypes.js.map +7 -0
- package/lib/esm/src/modules/tron/token/domain/TokenContextLoader.js +2 -0
- package/lib/esm/src/modules/tron/token/domain/TokenContextLoader.js.map +7 -0
- package/lib/esm/src/modules/tron/token/domain/TokenContextLoader.test.js +2 -0
- package/lib/esm/src/modules/tron/token/domain/TokenContextLoader.test.js.map +7 -0
- package/lib/esm/src/modules/tron/token/domain/parseTrc10AssetId.js +2 -0
- package/lib/esm/src/modules/tron/token/domain/parseTrc10AssetId.js.map +7 -0
- package/lib/esm/src/modules/tron/token/domain/parseTrc10AssetId.test.js +2 -0
- package/lib/esm/src/modules/tron/token/domain/parseTrc10AssetId.test.js.map +7 -0
- package/lib/esm/src/shared/domain/ContextModuleChainID.js +1 -1
- package/lib/esm/src/shared/domain/ContextModuleChainID.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/types/src/DefaultContextModule.d.ts.map +1 -1
- package/lib/types/src/di.d.ts.map +1 -1
- package/lib/types/src/index.d.ts +1 -0
- package/lib/types/src/index.d.ts.map +1 -1
- package/lib/types/src/modules/multichain/reporter/model/BlindSigningEvent.d.ts +1 -0
- package/lib/types/src/modules/multichain/reporter/model/BlindSigningEvent.d.ts.map +1 -1
- package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts +46 -2
- package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoDto.d.ts.map +1 -1
- package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts +19 -2
- package/lib/types/src/modules/solana/instruction-info/data/InstructionInfoMapper.d.ts.map +1 -1
- package/lib/types/src/modules/solana/model/SolanaClearSignContext.d.ts +1 -1
- package/lib/types/src/modules/solana/model/SolanaClearSignContext.d.ts.map +1 -1
- package/lib/types/src/modules/solana/model/SolanaPayloads.d.ts +54 -0
- package/lib/types/src/modules/solana/model/SolanaPayloads.d.ts.map +1 -1
- package/lib/types/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.d.ts +3 -2
- package/lib/types/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.d.ts.map +1 -1
- package/lib/types/src/modules/tron/model/TronTransactionContext.d.ts +5 -0
- package/lib/types/src/modules/tron/model/TronTransactionContext.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/data/HttpTokenDataSource.d.ts +17 -0
- package/lib/types/src/modules/tron/token/data/HttpTokenDataSource.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/data/HttpTokenDataSource.test.d.ts +2 -0
- package/lib/types/src/modules/tron/token/data/HttpTokenDataSource.test.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/data/TokenDataSource.d.ts +20 -0
- package/lib/types/src/modules/tron/token/data/TokenDataSource.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/di/tokenModuleFactory.d.ts +3 -0
- package/lib/types/src/modules/tron/token/di/tokenModuleFactory.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/di/tokenTypes.d.ts +5 -0
- package/lib/types/src/modules/tron/token/di/tokenTypes.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/domain/TokenContextLoader.d.ts +16 -0
- package/lib/types/src/modules/tron/token/domain/TokenContextLoader.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/domain/TokenContextLoader.test.d.ts +2 -0
- package/lib/types/src/modules/tron/token/domain/TokenContextLoader.test.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/domain/parseTrc10AssetId.d.ts +16 -0
- package/lib/types/src/modules/tron/token/domain/parseTrc10AssetId.d.ts.map +1 -0
- package/lib/types/src/modules/tron/token/domain/parseTrc10AssetId.test.d.ts +2 -0
- package/lib/types/src/modules/tron/token/domain/parseTrc10AssetId.test.d.ts.map +1 -0
- package/lib/types/src/shared/domain/ContextModuleChainID.d.ts +2 -1
- package/lib/types/src/shared/domain/ContextModuleChainID.d.ts.map +1 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts +2 -1
- package/lib/types/src/shared/model/ClearSignContext.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +5 -5
package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["HttpTokenAccountStateDataSource_exports", "__export", "HttpTokenAccountStateDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "import_HexStringUtils", "import_signedDescriptorDto", "HttpTokenAccountStateDataSource", "config", "http", "tokenAccount", "challenge", "dto", "error", "reason", "validated", "descriptor", "__decorateClass", "__decorateParam"]
|
|
4
|
+
"sourcesContent": ["import {\n DmkNetworkClient,\n LoggerPublisherService,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\nimport { HexStringUtils } from \"@/shared/utils/HexStringUtils\";\nimport { signedDescriptorDtoCodec } from \"@/shared/utils/signedDescriptorDto\";\n\nimport {\n type GetTokenAccountStateParams,\n type TokenAccountStateDataSource,\n type TokenAccountStateResult,\n} from \"./TokenAccountStateDataSource\";\n\ntype TokenAccountStateResponseDto = {\n descriptorType?: string;\n descriptorVersion?: number;\n tokenAccount?: string;\n mint?: string;\n owner?: string;\n preBalance?: number;\n nativePreBalance?: number; // wrappable lamport excess; absent = old backend\n signedDescriptor: string;\n keyId: string;\n keyUsage: string;\n};\n\n@injectable()\nexport class HttpTokenAccountStateDataSource\n implements TokenAccountStateDataSource\n{\n private logger: LoggerPublisherService;\n\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(configTypes.ContextModuleLoggerFactory)\n loggerFactory: (tag: string) => LoggerPublisherService,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {\n this.logger = loggerFactory(\"HttpTokenAccountStateDataSource\");\n }\n\n public async getTokenAccountState({\n tokenAccount,\n challenge,\n }: GetTokenAccountStateParams): Promise<\n Either<Error, TokenAccountStateResult>\n > {\n let dto: TokenAccountStateResponseDto;\n try {\n dto = (await this.http.get(\n `${this.config.metadataServiceDomain.url}/v2/solana/token-account-state/${tokenAccount}`,\n { params: { challenge } },\n )) as TokenAccountStateResponseDto;\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n return Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: ${reason}`,\n ),\n );\n }\n\n return signedDescriptorDtoCodec\n .decode(dto)\n .caseOf<Either<Error, TokenAccountStateResult>>({\n Left: (error) =>\n Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: malformed response for ${tokenAccount}: ${error}`,\n ),\n ),\n Right: (validated) => {\n if (dto.owner !== undefined && dto.mint === undefined) {\n this.logger.warn(\n \"[getTokenAccountState] response has owner but no mint \u2014 \" +\n \"canonical-ATA check will fail and the OWNER binding will be dropped by the device\",\n { data: { tokenAccount } },\n );\n }\n\n let descriptor: Uint8Array;\n try {\n descriptor = HexStringUtils.hexToBytes(validated.signedDescriptor);\n } catch (error) {\n return Left(\n new Error(\n `[ContextModule] HttpTokenAccountStateDataSource: invalid hex in signedDescriptor for ${tokenAccount}: ${(error as Error).message}`,\n ),\n );\n }\n\n if (dto.nativePreBalance === undefined) {\n this.logger.debug(\n \"[getTokenAccountState] nativePreBalance absent in response \u2014 native resets will not attest wrappable excess\",\n { data: { tokenAccount } },\n );\n }\n\n return Right({\n tokenAccount,\n descriptor,\n mint: dto.mint,\n keyId: validated.keyId,\n keyUsage: validated.keyUsage,\n });\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,IAAA,eAAAC,EAAAH,GAIA,IAAAI,EAAmC,qBACnCC,EAAoC,qBAEpCC,EAA4B,mCAE5BC,EAA6B,4CAC7BC,EAA+B,yCAC/BC,EAAyC,8CAsBlC,IAAMC,EAAN,KAEP,CAGE,YAEmBC,EAEjBC,EAEiBC,EACjB,CALiB,YAAAF,EAIA,UAAAE,EAEjB,KAAK,OAASD,EAAc,iCAAiC,CAC/D,CAXQ,OAaR,MAAa,qBAAqB,CAChC,aAAAE,EACA,UAAAC,CACF,EAEE,CACA,IAAIC,EACJ,GAAI,CACFA,EAAO,MAAM,KAAK,KAAK,IACrB,GAAG,KAAK,OAAO,sBAAsB,GAAG,kCAAkCF,CAAY,GACtF,CAAE,OAAQ,CAAE,UAAAC,CAAU,CAAE,CAC1B,CACF,OAASE,EAAO,CACd,MAAMC,EAASD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACpE,SAAO,QACL,IAAI,MACF,yFAAyFC,CAAM,EACjG,CACF,CACF,CAEA,OAAO,2BACJ,OAAOF,CAAG,EACV,OAA+C,CAC9C,KAAOC,MACL,QACE,IAAI,MACF,2EAA2EH,CAAY,KAAKG,CAAK,EACnG,CACF,EACF,MAAQE,GAAc,CAChBH,EAAI,QAAU,QAAaA,EAAI,OAAS,QAC1C,KAAK,OAAO,KACV,iJAEA,CAAE,KAAM,CAAE,aAAAF,CAAa,CAAE,CAC3B,EAGF,IAAIM,EACJ,GAAI,CACFA,EAAa,iBAAe,WAAWD,EAAU,gBAAgB,CACnE,OAASF,EAAO,CACd,SAAO,QACL,IAAI,MACF,wFAAwFH,CAAY,KAAMG,EAAgB,OAAO,EACnI,CACF,CACF,CAEA,OAAID,EAAI,mBAAqB,QAC3B,KAAK,OAAO,MACV,mHACA,CAAE,KAAM,CAAE,aAAAF,CAAa,CAAE,CAC3B,KAGK,SAAM,CACX,aAAAA,EACA,WAAAM,EACA,KAAMJ,EAAI,KACV,MAAOG,EAAU,MACjB,SAAUA,EAAU,QACtB,CAAC,CACH,CACF,CAAC,CACL,CACF,EAnFaT,EAANW,EAAA,IADN,cAAW,EAOPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,cAAY,0BAA0B,GAE7CA,EAAA,eAAO,eAAa,aAAa,IAVzBZ",
|
|
6
|
+
"names": ["HttpTokenAccountStateDataSource_exports", "__export", "HttpTokenAccountStateDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_networkTypes", "import_HexStringUtils", "import_signedDescriptorDto", "HttpTokenAccountStateDataSource", "config", "loggerFactory", "http", "tokenAccount", "challenge", "dto", "error", "reason", "validated", "descriptor", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
package/lib/cjs/src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=require("purify-ts"),e=require("vitest"),s=require("./HttpTokenAccountStateDataSource");const X={debug:e.vi.fn(),info:e.vi.fn(),warn:e.vi.fn(),error:e.vi.fn(),subscribers:[]},d=()=>X;(0,e.describe)("HttpTokenAccountStateDataSource",()=>{let o,n;const t="TokenAccountAddrXXXXXXXXXXXXXXXXXXXXXXXXXXX",a="deadbeef",i={metadataServiceDomain:{url:"https://nft.api.ledger.com"}};(0,e.beforeEach)(()=>{e.vi.clearAllMocks(),n={get:e.vi.fn()},o=new s.HttpTokenAccountStateDataSource(i,d,n)}),(0,e.it)("calls the metadata endpoint with the challenge param",async()=>{n.get.mockResolvedValue({descriptorType:"token_account_state",signedDescriptor:"01020304",keyId:"tas_key",keyUsage:"coin_meta"}),await o.getTokenAccountState({tokenAccount:t,challenge:a}),(0,e.expect)(n.get).toHaveBeenCalledWith(`https://nft.api.ledger.com/v2/solana/token-account-state/${t}`,{params:{challenge:a}})}),(0,e.it)("decodes signedDescriptor hex into Uint8Array",async()=>{n.get.mockResolvedValue({signedDescriptor:"deadbeef",keyId:"k",keyUsage:"u"});const r=await o.getTokenAccountState({tokenAccount:t,challenge:a});(0,e.expect)(r).toEqual((0,c.Right)({tokenAccount:t,descriptor:new Uint8Array([222,173,190,239]),keyId:"k",keyUsage:"u"}))}),(0,e.it)("returns Left on malformed response (missing signedDescriptor)",async()=>{n.get.mockResolvedValue({keyId:"k",keyUsage:"u"});const r=await o.getTokenAccountState({tokenAccount:t,challenge:a});(0,e.expect)(r.isLeft()).toBe(!0),(0,e.expect)(r.extract().message).toMatch(new RegExp(String.raw`\[ContextModule\] HttpTokenAccountStateDataSource: malformed response for ${t}:`))}),(0,e.it)("returns Left when signedDescriptor is not valid hex",async()=>{n.get.mockResolvedValue({signedDescriptor:"ZZZZ",keyId:"k",keyUsage:"u"});const r=await o.getTokenAccountState({tokenAccount:t,challenge:a});(0,e.expect)(r.isLeft()).toBe(!0),(0,e.expect)(r.extract().message).toMatch(/invalid hex/)}),(0,e.it)("returns Left when HTTP client throws",async()=>{n.get.mockRejectedValue(new Error("net"));const r=await o.getTokenAccountState({tokenAccount:t,challenge:a});(0,e.expect)(r).toEqual((0,c.Left)(new Error("[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: net")))}),(0,e.it)("logs debug when nativePreBalance is absent",async()=>{n.get.mockResolvedValue({signedDescriptor:"deadbeef",keyId:"k",keyUsage:"u"}),await o.getTokenAccountState({tokenAccount:t,challenge:a}),(0,e.expect)(X.debug).toHaveBeenCalledWith(e.expect.stringContaining("nativePreBalance absent"),e.expect.objectContaining({data:{tokenAccount:t}}))}),(0,e.it)("does not log debug when nativePreBalance is present",async()=>{n.get.mockResolvedValue({signedDescriptor:"deadbeef",keyId:"k",keyUsage:"u",nativePreBalance:1e3}),await o.getTokenAccountState({tokenAccount:t,challenge:a}),(0,e.expect)(X.debug).not.toHaveBeenCalled()}),(0,e.it)("logs warn when owner is present but mint is absent",async()=>{n.get.mockResolvedValue({signedDescriptor:"deadbeef",keyId:"k",keyUsage:"u",owner:"OwnerPubkeyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}),await o.getTokenAccountState({tokenAccount:t,challenge:a}),(0,e.expect)(X.warn).toHaveBeenCalledWith(e.expect.stringContaining("owner but no mint"),e.expect.objectContaining({data:{tokenAccount:t}}))}),(0,e.it)("does not log warn when both owner and mint are present",async()=>{n.get.mockResolvedValue({signedDescriptor:"deadbeef",keyId:"k",keyUsage:"u",owner:"OwnerPubkeyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",mint:"MintPubkeyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}),await o.getTokenAccountState({tokenAccount:t,challenge:a}),(0,e.expect)(X.warn).not.toHaveBeenCalled()})});
|
|
2
2
|
//# sourceMappingURL=HttpTokenAccountStateDataSource.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/modules/solana/token-account-state/data/HttpTokenAccountStateDataSource.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { HttpTokenAccountStateDataSource } from \"./HttpTokenAccountStateDataSource\";\nimport { type TokenAccountStateDataSource } from \"./TokenAccountStateDataSource\";\n\ndescribe(\"HttpTokenAccountStateDataSource\", () => {\n let datasource: TokenAccountStateDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const tokenAccount = \"TokenAccountAddrXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\n const challenge = \"deadbeef\";\n const config: ContextModuleServiceConfig = {\n metadataServiceDomain: { url: \"https://nft.api.ledger.com\" },\n } as ContextModuleServiceConfig;\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpTokenAccountStateDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls the metadata endpoint with the challenge param\", async () => {\n httpMock.get.mockResolvedValue({\n descriptorType: \"token_account_state\",\n signedDescriptor: \"01020304\",\n keyId: \"tas_key\",\n keyUsage: \"coin_meta\",\n });\n\n await datasource.getTokenAccountState({ tokenAccount, challenge });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n `https://nft.api.ledger.com/v2/solana/token-account-state/${tokenAccount}`,\n { params: { challenge } },\n );\n });\n\n it(\"decodes signedDescriptor hex into Uint8Array\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"deadbeef\",\n keyId: \"k\",\n keyUsage: \"u\",\n });\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result).toEqual(\n Right({\n tokenAccount,\n descriptor: new Uint8Array([0xde, 0xad, 0xbe, 0xef]),\n keyId: \"k\",\n keyUsage: \"u\",\n }),\n );\n });\n\n it(\"returns Left on malformed response (missing signedDescriptor)\", async () => {\n httpMock.get.mockResolvedValue({ keyId: \"k\", keyUsage: \"u\" });\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpTokenAccountStateDataSource: malformed response for ${tokenAccount}:`,\n ),\n );\n });\n\n it(\"returns Left when signedDescriptor is not valid hex\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"ZZZZ\",\n keyId: \"k\",\n keyUsage: \"u\",\n });\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(/invalid hex/);\n });\n\n it(\"returns Left when HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"net\"));\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: net\",\n ),\n ),\n );\n });\n});\n"],
|
|
5
|
-
"mappings": "aACA,IAAAA,EAA4B,qBAC5BC,EAAqD,kBAIrDC,EAAgD,
|
|
6
|
-
"names": ["import_purify_ts", "import_vitest", "import_HttpTokenAccountStateDataSource", "datasource", "httpMock", "tokenAccount", "challenge", "config", "result"]
|
|
4
|
+
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { HttpTokenAccountStateDataSource } from \"./HttpTokenAccountStateDataSource\";\nimport { type TokenAccountStateDataSource } from \"./TokenAccountStateDataSource\";\n\nconst mockLogger = {\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n subscribers: [],\n};\nconst mockLoggerFactory = () => mockLogger;\n\ndescribe(\"HttpTokenAccountStateDataSource\", () => {\n let datasource: TokenAccountStateDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const tokenAccount = \"TokenAccountAddrXXXXXXXXXXXXXXXXXXXXXXXXXXX\";\n const challenge = \"deadbeef\";\n const config: ContextModuleServiceConfig = {\n metadataServiceDomain: { url: \"https://nft.api.ledger.com\" },\n } as ContextModuleServiceConfig;\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpTokenAccountStateDataSource(\n config,\n mockLoggerFactory,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"calls the metadata endpoint with the challenge param\", async () => {\n httpMock.get.mockResolvedValue({\n descriptorType: \"token_account_state\",\n signedDescriptor: \"01020304\",\n keyId: \"tas_key\",\n keyUsage: \"coin_meta\",\n });\n\n await datasource.getTokenAccountState({ tokenAccount, challenge });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n `https://nft.api.ledger.com/v2/solana/token-account-state/${tokenAccount}`,\n { params: { challenge } },\n );\n });\n\n it(\"decodes signedDescriptor hex into Uint8Array\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"deadbeef\",\n keyId: \"k\",\n keyUsage: \"u\",\n });\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result).toEqual(\n Right({\n tokenAccount,\n descriptor: new Uint8Array([0xde, 0xad, 0xbe, 0xef]),\n keyId: \"k\",\n keyUsage: \"u\",\n }),\n );\n });\n\n it(\"returns Left on malformed response (missing signedDescriptor)\", async () => {\n httpMock.get.mockResolvedValue({ keyId: \"k\", keyUsage: \"u\" });\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(\n new RegExp(\n String.raw`\\[ContextModule\\] HttpTokenAccountStateDataSource: malformed response for ${tokenAccount}:`,\n ),\n );\n });\n\n it(\"returns Left when signedDescriptor is not valid hex\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"ZZZZ\",\n keyId: \"k\",\n keyUsage: \"u\",\n });\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result.isLeft()).toBe(true);\n expect((result.extract() as Error).message).toMatch(/invalid hex/);\n });\n\n it(\"returns Left when HTTP client throws\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"net\"));\n\n const result = await datasource.getTokenAccountState({\n tokenAccount,\n challenge,\n });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenAccountStateDataSource: Failed to fetch token account state: net\",\n ),\n ),\n );\n });\n\n it(\"logs debug when nativePreBalance is absent\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"deadbeef\",\n keyId: \"k\",\n keyUsage: \"u\",\n });\n\n await datasource.getTokenAccountState({ tokenAccount, challenge });\n\n expect(mockLogger.debug).toHaveBeenCalledWith(\n expect.stringContaining(\"nativePreBalance absent\"),\n expect.objectContaining({ data: { tokenAccount } }),\n );\n });\n\n it(\"does not log debug when nativePreBalance is present\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"deadbeef\",\n keyId: \"k\",\n keyUsage: \"u\",\n nativePreBalance: 1000,\n });\n\n await datasource.getTokenAccountState({ tokenAccount, challenge });\n\n expect(mockLogger.debug).not.toHaveBeenCalled();\n });\n\n it(\"logs warn when owner is present but mint is absent\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"deadbeef\",\n keyId: \"k\",\n keyUsage: \"u\",\n owner: \"OwnerPubkeyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\n });\n\n await datasource.getTokenAccountState({ tokenAccount, challenge });\n\n expect(mockLogger.warn).toHaveBeenCalledWith(\n expect.stringContaining(\"owner but no mint\"),\n expect.objectContaining({ data: { tokenAccount } }),\n );\n });\n\n it(\"does not log warn when both owner and mint are present\", async () => {\n httpMock.get.mockResolvedValue({\n signedDescriptor: \"deadbeef\",\n keyId: \"k\",\n keyUsage: \"u\",\n owner: \"OwnerPubkeyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\n mint: \"MintPubkeyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\",\n });\n\n await datasource.getTokenAccountState({ tokenAccount, challenge });\n\n expect(mockLogger.warn).not.toHaveBeenCalled();\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_purify_ts", "import_vitest", "import_HttpTokenAccountStateDataSource", "mockLogger", "mockLoggerFactory", "datasource", "httpMock", "tokenAccount", "challenge", "config", "result"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(r,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of T(n))!c.call(r,t)&&t!==e&&o(r,t,{get:()=>n[t],enumerable:!(a=i(n,t))||a.enumerable});return r};var s=r=>p(o({},"__esModule",{value:!0}),r);var x={};module.exports=s(x);
|
|
2
|
+
//# sourceMappingURL=TronTransactionContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/tron/model/TronTransactionContext.ts"],
|
|
4
|
+
"sourcesContent": ["export type TronTransactionContext = {\n /** Protobuf-serialized `Transaction.raw` bytes, as given to the signer. */\n rawTransaction: Uint8Array;\n};\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["TronTransactionContext_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var f=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var C=(r,e)=>{for(var o in e)f(r,o,{get:e[o],enumerable:!0})},w=(r,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of u(e))!y.call(r,t)&&t!==o&&f(r,t,{get:()=>e[t],enumerable:!(n=d(e,t))||n.enumerable});return r};var T=r=>w(f({},"__esModule",{value:!0}),r),l=(r,e,o,n)=>{for(var t=n>1?void 0:n?d(e,o):e,i=r.length-1,m;i>=0;i--)(m=r[i])&&(t=(n?m(e,o,t):m(t))||t);return n&&t&&f(e,o,t),t},p=(r,e)=>(o,n)=>e(o,n,r);var x={};C(x,{HttpTokenDataSource:()=>a});module.exports=T(x);var s=require("inversify"),c=require("purify-ts"),k=require("../../../../config/di/configTypes"),g=require("../../../../modules/tron/token/data/TokenDataSource"),h=require("../../../../shared/network/di/networkTypes");let a=class{constructor(e,o){this.config=e;this.http=o}async getTokenInfosPayload({assetId:e}){const o=()=>(0,c.Left)(new Error(`[ContextModule] HttpTokenDataSource: no token metadata for asset id ${e}`));try{const n=await this.http.get(`${this.config.cal.url}/tokens`,{params:{id:`tron/trc10/${e}`,output:"id,ticker,decimals,descriptor",ref:`branch:${this.config.cal.branch}`}});return g.tokenDataResponsesCodec.decode(n).caseOf({Left:o,Right:t=>{const i=t[0]?.descriptor.signatures[this.config.cal.mode];return i===void 0||i.length===0?o():(0,c.Right)(i)}})}catch{return(0,c.Left)(new Error("[ContextModule] HttpTokenDataSource: Failed to fetch token informations"))}}};a=l([(0,s.injectable)(),p(0,(0,s.inject)(k.configTypes.Config)),p(1,(0,s.inject)(h.networkTypes.NetworkClient))],a);0&&(module.exports={HttpTokenDataSource});
|
|
2
|
+
//# sourceMappingURL=HttpTokenDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/data/HttpTokenDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import { DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\nimport { type Either, Left, Right } from \"purify-ts\";\n\nimport { configTypes } from \"@/config/di/configTypes\";\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\nimport {\n type GetTokenInfosParams,\n tokenDataResponsesCodec,\n type TokenDataSource,\n} from \"@/modules/tron/token/data/TokenDataSource\";\nimport { networkTypes } from \"@/shared/network/di/networkTypes\";\n\n@injectable()\nexport class HttpTokenDataSource implements TokenDataSource {\n constructor(\n @inject(configTypes.Config)\n private readonly config: ContextModuleServiceConfig,\n @inject(networkTypes.NetworkClient)\n private readonly http: DmkNetworkClient,\n ) {}\n\n /**\n * Unlike the EVM descriptor, which is assembled from `descriptor.data` plus a\n * signature, the whole TRC10 payload the device expects is the signature\n * field: a protobuf `TokenDetails` the app checks against its built-in key.\n * `descriptor.data` is empty for these entries.\n */\n public async getTokenInfosPayload({\n assetId,\n }: GetTokenInfosParams): Promise<Either<Error, string>> {\n const noTokenMetadata = () =>\n Left(\n new Error(\n `[ContextModule] HttpTokenDataSource: no token metadata for asset id ${assetId}`,\n ),\n );\n\n try {\n const response = await this.http.get(`${this.config.cal.url}/tokens`, {\n params: {\n id: `tron/trc10/${assetId}`,\n output: \"id,ticker,decimals,descriptor\",\n ref: `branch:${this.config.cal.branch}`,\n },\n });\n\n return tokenDataResponsesCodec.decode(response).caseOf({\n Left: noTokenMetadata,\n Right: (entries) => {\n const payload =\n entries[0]?.descriptor.signatures[this.config.cal.mode];\n\n return payload === undefined || payload.length === 0\n ? noTokenMetadata()\n : Right(payload);\n },\n });\n } catch (_error) {\n return Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: Failed to fetch token informations\",\n ),\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAmC,qBACnCC,EAAyC,qBAEzCC,EAA4B,mCAE5BC,EAIO,qDACPC,EAA6B,4CAGtB,IAAMC,EAAN,KAAqD,CAC1D,YAEmBC,EAEAC,EACjB,CAHiB,YAAAD,EAEA,UAAAC,CAChB,CAQH,MAAa,qBAAqB,CAChC,QAAAC,CACF,EAAwD,CACtD,MAAMC,EAAkB,OACtB,QACE,IAAI,MACF,uEAAuED,CAAO,EAChF,CACF,EAEF,GAAI,CACF,MAAME,EAAW,MAAM,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,UAAW,CACpE,OAAQ,CACN,GAAI,cAAcF,CAAO,GACzB,OAAQ,gCACR,IAAK,UAAU,KAAK,OAAO,IAAI,MAAM,EACvC,CACF,CAAC,EAED,OAAO,0BAAwB,OAAOE,CAAQ,EAAE,OAAO,CACrD,KAAMD,EACN,MAAQE,GAAY,CAClB,MAAMC,EACJD,EAAQ,CAAC,GAAG,WAAW,WAAW,KAAK,OAAO,IAAI,IAAI,EAExD,OAAOC,IAAY,QAAaA,EAAQ,SAAW,EAC/CH,EAAgB,KAChB,SAAMG,CAAO,CACnB,CACF,CAAC,CACH,MAAiB,CACf,SAAO,QACL,IAAI,MACF,yEACF,CACF,CACF,CACF,CACF,EApDaP,EAANQ,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,cAAY,MAAM,GAEzBA,EAAA,eAAO,eAAa,aAAa,IAJzBT",
|
|
6
|
+
"names": ["HttpTokenDataSource_exports", "__export", "HttpTokenDataSource", "__toCommonJS", "import_inversify", "import_purify_ts", "import_configTypes", "import_TokenDataSource", "import_networkTypes", "HttpTokenDataSource", "config", "http", "assetId", "noTokenMetadata", "response", "entries", "payload", "__decorateClass", "__decorateParam"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=require("purify-ts"),e=require("vitest"),i=require("./HttpTokenDataSource");(0,e.describe)("HttpTokenDataSource",()=>{let a,o;const r="1002000",c={cal:{url:"https://global.api.prd.ledger.com/cal/v1",mode:"prod",branch:"main"}},s=t=>[{id:`tron/trc10/${r}`,ticker:"BTTOLD",decimals:6,descriptor:{data:"",descriptorType:"token",signatures:t}}];(0,e.beforeEach)(()=>{e.vi.clearAllMocks(),o={get:e.vi.fn()},a=new i.HttpTokenDataSource(c,o)}),(0,e.it)("should call http.get with the correct url and params",async()=>{o.get.mockResolvedValue([]),await a.getTokenInfosPayload({assetId:r}),(0,e.expect)(o.get).toHaveBeenCalledWith("https://global.api.prd.ledger.com/cal/v1/tokens",{params:{id:"tron/trc10/1002000",output:"id,ticker,decimals,descriptor",ref:"branch:main"}})}),(0,e.it)("should return the signature matching the configured mode",async()=>{o.get.mockResolvedValue(s({prod:"prod-sig",test:"test-sig"}));const t=await a.getTokenInfosPayload({assetId:r});(0,e.expect)(t).toEqual((0,n.Right)("prod-sig"))}),(0,e.it)("should return an error when no token matches",async()=>{o.get.mockResolvedValue([]);const t=await a.getTokenInfosPayload({assetId:r});(0,e.expect)(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: no token metadata for asset id 1002000")))}),(0,e.it)("should return an error when the descriptor carries no signature",async()=>{o.get.mockResolvedValue(s({prod:"",test:"test-sig"}));const t=await a.getTokenInfosPayload({assetId:r});(0,e.expect)(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: no token metadata for asset id 1002000")))}),e.it.each([["the response is not a list",{descriptor:{}}],["an entry carries no descriptor",[{id:`tron/trc10/${r}`}]],["the descriptor carries no signature field",[{descriptor:{data:"",descriptorType:"token"}}]],["a signature is not a string",[{descriptor:{signatures:{prod:42,test:"test-sig"}}}]]])("should return an error when %s",async(t,d)=>{o.get.mockResolvedValue(d);const l=await a.getTokenInfosPayload({assetId:r});(0,e.expect)(l).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: no token metadata for asset id 1002000")))}),(0,e.it)("should return an error when the request fails",async()=>{o.get.mockRejectedValue(new Error("network"));const t=await a.getTokenInfosPayload({assetId:r});(0,e.expect)(t).toEqual((0,n.Left)(new Error("[ContextModule] HttpTokenDataSource: Failed to fetch token informations")))})});
|
|
2
|
+
//# sourceMappingURL=HttpTokenDataSource.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/data/HttpTokenDataSource.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { type DmkNetworkClient } from \"@ledgerhq/device-management-kit\";\nimport { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type ContextModuleServiceConfig } from \"@/config/model/ContextModuleConfig\";\n\nimport { HttpTokenDataSource } from \"./HttpTokenDataSource\";\nimport { type TokenDataSource } from \"./TokenDataSource\";\n\ndescribe(\"HttpTokenDataSource\", () => {\n let datasource: TokenDataSource;\n let httpMock: { get: ReturnType<typeof vi.fn> };\n const assetId = \"1002000\";\n const config: ContextModuleServiceConfig = {\n cal: {\n url: \"https://global.api.prd.ledger.com/cal/v1\",\n mode: \"prod\",\n branch: \"main\",\n },\n } as ContextModuleServiceConfig;\n\n const response = (signatures: { prod: string; test: string }) => [\n {\n id: `tron/trc10/${assetId}`,\n ticker: \"BTTOLD\",\n decimals: 6,\n descriptor: { data: \"\", descriptorType: \"token\", signatures },\n },\n ];\n\n beforeEach(() => {\n vi.clearAllMocks();\n httpMock = { get: vi.fn() };\n datasource = new HttpTokenDataSource(\n config,\n httpMock as unknown as DmkNetworkClient,\n );\n });\n\n it(\"should call http.get with the correct url and params\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n await datasource.getTokenInfosPayload({ assetId });\n\n expect(httpMock.get).toHaveBeenCalledWith(\n \"https://global.api.prd.ledger.com/cal/v1/tokens\",\n {\n params: {\n id: \"tron/trc10/1002000\",\n output: \"id,ticker,decimals,descriptor\",\n ref: \"branch:main\",\n },\n },\n );\n });\n\n it(\"should return the signature matching the configured mode\", async () => {\n httpMock.get.mockResolvedValue(\n response({ prod: \"prod-sig\", test: \"test-sig\" }),\n );\n\n const result = await datasource.getTokenInfosPayload({ assetId });\n\n expect(result).toEqual(Right(\"prod-sig\"));\n });\n\n it(\"should return an error when no token matches\", async () => {\n httpMock.get.mockResolvedValue([]);\n\n const result = await datasource.getTokenInfosPayload({ assetId });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for asset id 1002000\",\n ),\n ),\n );\n });\n\n it(\"should return an error when the descriptor carries no signature\", async () => {\n httpMock.get.mockResolvedValue(response({ prod: \"\", test: \"test-sig\" }));\n\n const result = await datasource.getTokenInfosPayload({ assetId });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for asset id 1002000\",\n ),\n ),\n );\n });\n\n it.each([\n [\"the response is not a list\", { descriptor: {} }],\n [\"an entry carries no descriptor\", [{ id: `tron/trc10/${assetId}` }]],\n [\n \"the descriptor carries no signature field\",\n [{ descriptor: { data: \"\", descriptorType: \"token\" } }],\n ],\n [\n \"a signature is not a string\",\n [{ descriptor: { signatures: { prod: 42, test: \"test-sig\" } } }],\n ],\n ])(\"should return an error when %s\", async (_case, payload) => {\n httpMock.get.mockResolvedValue(payload);\n\n const result = await datasource.getTokenInfosPayload({ assetId });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: no token metadata for asset id 1002000\",\n ),\n ),\n );\n });\n\n it(\"should return an error when the request fails\", async () => {\n httpMock.get.mockRejectedValue(new Error(\"network\"));\n\n const result = await datasource.getTokenInfosPayload({ assetId });\n\n expect(result).toEqual(\n Left(\n new Error(\n \"[ContextModule] HttpTokenDataSource: Failed to fetch token informations\",\n ),\n ),\n );\n });\n});\n"],
|
|
5
|
+
"mappings": "aACA,IAAAA,EAA4B,qBAC5BC,EAAqD,kBAIrDC,EAAoC,oCAGpC,YAAS,sBAAuB,IAAM,CACpC,IAAIC,EACAC,EACJ,MAAMC,EAAU,UACVC,EAAqC,CACzC,IAAK,CACH,IAAK,2CACL,KAAM,OACN,OAAQ,MACV,CACF,EAEMC,EAAYC,GAA+C,CAC/D,CACE,GAAI,cAAcH,CAAO,GACzB,OAAQ,SACR,SAAU,EACV,WAAY,CAAE,KAAM,GAAI,eAAgB,QAAS,WAAAG,CAAW,CAC9D,CACF,KAEA,cAAW,IAAM,CACf,KAAG,cAAc,EACjBJ,EAAW,CAAE,IAAK,KAAG,GAAG,CAAE,EAC1BD,EAAa,IAAI,sBACfG,EACAF,CACF,CACF,CAAC,KAED,MAAG,uDAAwD,SAAY,CACrEA,EAAS,IAAI,kBAAkB,CAAC,CAAC,EAEjC,MAAMD,EAAW,qBAAqB,CAAE,QAAAE,CAAQ,CAAC,KAEjD,UAAOD,EAAS,GAAG,EAAE,qBACnB,kDACA,CACE,OAAQ,CACN,GAAI,qBACJ,OAAQ,gCACR,IAAK,aACP,CACF,CACF,CACF,CAAC,KAED,MAAG,2DAA4D,SAAY,CACzEA,EAAS,IAAI,kBACXG,EAAS,CAAE,KAAM,WAAY,KAAM,UAAW,CAAC,CACjD,EAEA,MAAME,EAAS,MAAMN,EAAW,qBAAqB,CAAE,QAAAE,CAAQ,CAAC,KAEhE,UAAOI,CAAM,EAAE,WAAQ,SAAM,UAAU,CAAC,CAC1C,CAAC,KAED,MAAG,+CAAgD,SAAY,CAC7DL,EAAS,IAAI,kBAAkB,CAAC,CAAC,EAEjC,MAAMK,EAAS,MAAMN,EAAW,qBAAqB,CAAE,QAAAE,CAAQ,CAAC,KAEhE,UAAOI,CAAM,EAAE,WACb,QACE,IAAI,MACF,6EACF,CACF,CACF,CACF,CAAC,KAED,MAAG,kEAAmE,SAAY,CAChFL,EAAS,IAAI,kBAAkBG,EAAS,CAAE,KAAM,GAAI,KAAM,UAAW,CAAC,CAAC,EAEvE,MAAME,EAAS,MAAMN,EAAW,qBAAqB,CAAE,QAAAE,CAAQ,CAAC,KAEhE,UAAOI,CAAM,EAAE,WACb,QACE,IAAI,MACF,6EACF,CACF,CACF,CACF,CAAC,EAED,KAAG,KAAK,CACN,CAAC,6BAA8B,CAAE,WAAY,CAAC,CAAE,CAAC,EACjD,CAAC,iCAAkC,CAAC,CAAE,GAAI,cAAcJ,CAAO,EAAG,CAAC,CAAC,EACpE,CACE,4CACA,CAAC,CAAE,WAAY,CAAE,KAAM,GAAI,eAAgB,OAAQ,CAAE,CAAC,CACxD,EACA,CACE,8BACA,CAAC,CAAE,WAAY,CAAE,WAAY,CAAE,KAAM,GAAI,KAAM,UAAW,CAAE,CAAE,CAAC,CACjE,CACF,CAAC,EAAE,iCAAkC,MAAOK,EAAOC,IAAY,CAC7DP,EAAS,IAAI,kBAAkBO,CAAO,EAEtC,MAAMF,EAAS,MAAMN,EAAW,qBAAqB,CAAE,QAAAE,CAAQ,CAAC,KAEhE,UAAOI,CAAM,EAAE,WACb,QACE,IAAI,MACF,6EACF,CACF,CACF,CACF,CAAC,KAED,MAAG,gDAAiD,SAAY,CAC9DL,EAAS,IAAI,kBAAkB,IAAI,MAAM,SAAS,CAAC,EAEnD,MAAMK,EAAS,MAAMN,EAAW,qBAAqB,CAAE,QAAAE,CAAQ,CAAC,KAEhE,UAAOI,CAAM,EAAE,WACb,QACE,IAAI,MACF,yEACF,CACF,CACF,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_purify_ts", "import_vitest", "import_HttpTokenDataSource", "datasource", "httpMock", "assetId", "config", "response", "signatures", "result", "_case", "payload"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},d=(t,e,a,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of p(e))!c.call(t,o)&&o!==a&&s(t,o,{get:()=>e[o],enumerable:!(n=i(e,o))||n.enumerable});return t};var m=t=>d(s({},"__esModule",{value:!0}),t);var k={};f(k,{tokenDataResponsesCodec:()=>g});module.exports=m(k);var r=require("purify-ts");const g=(0,r.array)(r.Codec.interface({descriptor:r.Codec.interface({signatures:r.Codec.interface({prod:r.string,test:r.string})})}));0&&(module.exports={tokenDataResponsesCodec});
|
|
2
|
+
//# sourceMappingURL=TokenDataSource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/data/TokenDataSource.ts"],
|
|
4
|
+
"sourcesContent": ["import { array, Codec, type Either, string } from \"purify-ts\";\n\nexport type GetTokenInfosParams = {\n assetId: string;\n};\n\n/**\n * Only the fields the payload is read from are validated: a CAL change to the\n * ones we ignore must not downgrade a signable descriptor to a blind signature.\n */\nexport const tokenDataResponsesCodec = array(\n Codec.interface({\n descriptor: Codec.interface({\n signatures: Codec.interface({\n prod: string,\n test: string,\n }),\n }),\n }),\n);\n\nexport interface TokenDataSource {\n getTokenInfosPayload(\n params: GetTokenInfosParams,\n ): Promise<Either<Error, string>>;\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkD,qBAU3C,MAAMF,KAA0B,SACrC,QAAM,UAAU,CACd,WAAY,QAAM,UAAU,CAC1B,WAAY,QAAM,UAAU,CAC1B,KAAM,SACN,KAAM,QACR,CAAC,CACH,CAAC,CACH,CAAC,CACH",
|
|
6
|
+
"names": ["TokenDataSource_exports", "__export", "tokenDataResponsesCodec", "__toCommonJS", "import_purify_ts"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var u=(o,t)=>{for(var r in t)n(o,r,{get:t[r],enumerable:!0})},d=(o,t,r,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of f(t))!i.call(o,e)&&e!==r&&n(o,e,{get:()=>t[e],enumerable:!(m=c(t,e))||m.enumerable});return o};var x=o=>d(n({},"__esModule",{value:!0}),o);var l={};u(l,{tokenModuleFactory:()=>C});module.exports=x(l);var p=require("inversify"),k=require("../../../../modules/tron/token/data/HttpTokenDataSource"),a=require("../../../../modules/tron/token/di/tokenTypes"),T=require("../../../../modules/tron/token/domain/TokenContextLoader");const C=()=>new p.ContainerModule(({bind:o})=>{o(a.tokenTypes.TokenDataSource).to(k.HttpTokenDataSource),o(a.tokenTypes.TokenContextLoader).to(T.TokenContextLoader)});0&&(module.exports={tokenModuleFactory});
|
|
2
|
+
//# sourceMappingURL=tokenModuleFactory.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/di/tokenModuleFactory.ts"],
|
|
4
|
+
"sourcesContent": ["import { ContainerModule } from \"inversify\";\n\nimport { HttpTokenDataSource } from \"@/modules/tron/token/data/HttpTokenDataSource\";\nimport { tokenTypes } from \"@/modules/tron/token/di/tokenTypes\";\nimport { TokenContextLoader } from \"@/modules/tron/token/domain/TokenContextLoader\";\n\nexport const tokenModuleFactory = () =>\n new ContainerModule(({ bind }) => {\n bind(tokenTypes.TokenDataSource).to(HttpTokenDataSource);\n bind(tokenTypes.TokenContextLoader).to(TokenContextLoader);\n });\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgC,qBAEhCC,EAAoC,yDACpCC,EAA2B,8CAC3BC,EAAmC,0DAE5B,MAAML,EAAqB,IAChC,IAAI,kBAAgB,CAAC,CAAE,KAAAM,CAAK,IAAM,CAChCA,EAAK,aAAW,eAAe,EAAE,GAAG,qBAAmB,EACvDA,EAAK,aAAW,kBAAkB,EAAE,GAAG,oBAAkB,CAC3D,CAAC",
|
|
6
|
+
"names": ["tokenModuleFactory_exports", "__export", "tokenModuleFactory", "__toCommonJS", "import_inversify", "import_HttpTokenDataSource", "import_tokenTypes", "import_TokenContextLoader", "bind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var c=(e,o)=>{for(var n in o)r(e,n,{get:o[n],enumerable:!0})},x=(e,o,n,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of T(o))!S.call(e,t)&&t!==n&&r(e,t,{get:()=>o[t],enumerable:!(a=k(o,t))||a.enumerable});return e};var y=e=>x(r({},"__esModule",{value:!0}),e);var d={};c(d,{tokenTypes:()=>b});module.exports=y(d);const b={TokenDataSource:Symbol.for("TokenDataSource"),TokenContextLoader:Symbol.for("TokenContextLoader")};0&&(module.exports={tokenTypes});
|
|
2
|
+
//# sourceMappingURL=tokenTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/di/tokenTypes.ts"],
|
|
4
|
+
"sourcesContent": ["export const tokenTypes = {\n TokenDataSource: Symbol.for(\"TokenDataSource\"),\n TokenContextLoader: Symbol.for(\"TokenContextLoader\"),\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAa,CACxB,gBAAiB,OAAO,IAAI,iBAAiB,EAC7C,mBAAoB,OAAO,IAAI,oBAAoB,CACrD",
|
|
6
|
+
"names": ["tokenTypes_exports", "__export", "tokenTypes", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var x=(o,t)=>{for(var n in t)i(o,n,{get:t[n],enumerable:!0})},g=(o,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of S(t))!d.call(o,e)&&e!==n&&i(o,e,{get:()=>t[e],enumerable:!(a=l(t,e))||a.enumerable});return o};var u=o=>g(i({},"__esModule",{value:!0}),o),y=(o,t,n,a)=>{for(var e=a>1?void 0:a?l(t,n):t,T=o.length-1,p;T>=0;T--)(p=o[T])&&(e=(a?p(t,n,e):p(e))||e);return a&&e&&i(t,n,e),e},m=(o,t)=>(n,a)=>t(n,a,o);var R={};x(R,{TokenContextLoader:()=>r});module.exports=u(R);var c=require("inversify"),C=require("../../../../modules/tron/token/di/tokenTypes"),f=require("../../../../modules/tron/token/domain/parseTrc10AssetId"),s=require("../../../../shared/model/ClearSignContext");const O=[s.ClearSignContextType.TRON_TOKEN];let r=class{constructor(t){this.dataSource=t}canHandle(t,n){return O.every(a=>n.includes(a))&&typeof t=="object"&&t!==null&&"rawTransaction"in t&&t.rawTransaction instanceof Uint8Array&&t.rawTransaction.length>0}async load({rawTransaction:t}){const n=(0,f.parseTrc10AssetId)(t);return n===void 0?[]:(await this.dataSource.getTokenInfosPayload({assetId:n})).caseOf({Left:e=>[{type:s.ClearSignContextType.ERROR,error:e}],Right:e=>[{type:s.ClearSignContextType.TRON_TOKEN,payload:e}]})}};r=y([(0,c.injectable)(),m(0,(0,c.inject)(C.tokenTypes.TokenDataSource))],r);0&&(module.exports={TokenContextLoader});
|
|
2
|
+
//# sourceMappingURL=TokenContextLoader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/domain/TokenContextLoader.ts"],
|
|
4
|
+
"sourcesContent": ["import { inject, injectable } from \"inversify\";\n\nimport { type TronTransactionContext } from \"@/modules/tron/model/TronTransactionContext\";\nimport { type TokenDataSource } from \"@/modules/tron/token/data/TokenDataSource\";\nimport { tokenTypes } from \"@/modules/tron/token/di/tokenTypes\";\nimport { parseTrc10AssetId } from \"@/modules/tron/token/domain/parseTrc10AssetId\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nconst SUPPORTED_TYPES: ClearSignContextType[] = [\n ClearSignContextType.TRON_TOKEN,\n];\n\n@injectable()\nexport class TokenContextLoader\n implements ContextLoader<TronTransactionContext>\n{\n constructor(\n @inject(tokenTypes.TokenDataSource)\n private readonly dataSource: TokenDataSource,\n ) {}\n\n canHandle(\n input: unknown,\n expectedTypes: ClearSignContextType[],\n ): input is TronTransactionContext {\n return (\n SUPPORTED_TYPES.every((type) => expectedTypes.includes(type)) &&\n typeof input === \"object\" &&\n input !== null &&\n \"rawTransaction\" in input &&\n input.rawTransaction instanceof Uint8Array &&\n input.rawTransaction.length > 0\n );\n }\n\n /**\n * A transaction carrying no TRC10 transfer yields no context rather than an\n * error: the device reviews it unchanged, which is the normal outcome for\n * every TRX and TRC20 transfer.\n */\n async load({\n rawTransaction,\n }: TronTransactionContext): Promise<ClearSignContext[]> {\n const assetId = parseTrc10AssetId(rawTransaction);\n if (assetId === undefined) return [];\n\n const payload = await this.dataSource.getTokenInfosPayload({ assetId });\n\n return payload.caseOf({\n Left: (error): ClearSignContext[] => [\n { type: ClearSignContextType.ERROR, error },\n ],\n Right: (value): ClearSignContext[] => [\n { type: ClearSignContextType.TRON_TOKEN, payload: value },\n ],\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAmC,qBAInCC,EAA2B,8CAC3BC,EAAkC,yDAElCC,EAGO,2CAEP,MAAMC,EAA0C,CAC9C,uBAAqB,UACvB,EAGO,IAAMC,EAAN,KAEP,CACE,YAEmBC,EACjB,CADiB,gBAAAA,CAChB,CAEH,UACEC,EACAC,EACiC,CACjC,OACEJ,EAAgB,MAAOK,GAASD,EAAc,SAASC,CAAI,CAAC,GAC5D,OAAOF,GAAU,UACjBA,IAAU,MACV,mBAAoBA,GACpBA,EAAM,0BAA0B,YAChCA,EAAM,eAAe,OAAS,CAElC,CAOA,MAAM,KAAK,CACT,eAAAG,CACF,EAAwD,CACtD,MAAMC,KAAU,qBAAkBD,CAAc,EAChD,OAAIC,IAAY,OAAkB,CAAC,GAEnB,MAAM,KAAK,WAAW,qBAAqB,CAAE,QAAAA,CAAQ,CAAC,GAEvD,OAAO,CACpB,KAAOC,GAA8B,CACnC,CAAE,KAAM,uBAAqB,MAAO,MAAAA,CAAM,CAC5C,EACA,MAAQC,GAA8B,CACpC,CAAE,KAAM,uBAAqB,WAAY,QAASA,CAAM,CAC1D,CACF,CAAC,CACH,CACF,EA5CaR,EAANS,EAAA,IADN,cAAW,EAKPC,EAAA,eAAO,aAAW,eAAe,IAJzBV",
|
|
6
|
+
"names": ["TokenContextLoader_exports", "__export", "TokenContextLoader", "__toCommonJS", "import_inversify", "import_tokenTypes", "import_parseTrc10AssetId", "import_ClearSignContext", "SUPPORTED_TYPES", "TokenContextLoader", "dataSource", "input", "expectedTypes", "type", "rawTransaction", "assetId", "error", "value", "__decorateClass", "__decorateParam"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var d=require("purify-ts"),e=require("vitest"),t=require("../../../../shared/model/ClearSignContext"),s=require("./TokenContextLoader");const l=o=>Uint8Array.from(o.match(/.{2}/g).map(a=>parseInt(a,16))),c=l("0a023dce220895da42177db005074080d095ffbc315a75080212710a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e7472616374123b0a0731303032303030121541c8599111f29c1e1e061265b4af93ea1f274ad78a1a154114183f3bbca4ae9fc1de55b9bbe2d071942dc1a62087ad4b70a0fb91ffbc31"),T=l("0a023dce220895da42177db0050740d8e0a5feed2d522c43727970746f436861696e2d54726f6e5352204c6564676572205472616e73616374696f6e732054657374735a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a1541c8599111f29c1e1e061265b4af93ea1f274ad78a121541c8599111f29c1e1e061265b4af93ea1f274ad78a1880c2d72f709d94a2feed2d"),f="0a0a426974546f7272656e7410061a46304402202e2502f36b00e57be785fc79ec4043abcdd4fdd1b58d737ce123599dffad2cb602201702c307f009d014a553503b499591558b3634ceee4c054c61cedd8aca94c02b";(0,e.describe)("TokenContextLoader",()=>{let o,a;(0,e.beforeEach)(()=>{e.vi.restoreAllMocks(),o={getTokenInfosPayload:e.vi.fn()},a=new s.TokenContextLoader(o)}),(0,e.describe)("canHandle",()=>{(0,e.it)("should handle a raw transaction when the token type is expected",()=>{(0,e.expect)(a.canHandle({rawTransaction:c},[t.ClearSignContextType.TRON_TOKEN])).toBe(!0)}),(0,e.it)("should not handle it when the token type is not expected",()=>{(0,e.expect)(a.canHandle({rawTransaction:c},[t.ClearSignContextType.ETHEREUM_TOKEN])).toBe(!1)}),e.it.each([["null",null],["an empty object",{}],["a hex string",{rawTransaction:"0a023dce"}],["an empty transaction",{rawTransaction:new Uint8Array}]])("should not handle %s",(n,r)=>{(0,e.expect)(a.canHandle(r,[t.ClearSignContextType.TRON_TOKEN])).toBe(!1)})}),(0,e.describe)("load",()=>{(0,e.it)("should return the token context of a TRC10 transfer",async()=>{e.vi.spyOn(o,"getTokenInfosPayload").mockResolvedValue((0,d.Right)(f));const n=await a.load({rawTransaction:c});(0,e.expect)(o.getTokenInfosPayload).toHaveBeenCalledWith({assetId:"1002000"}),(0,e.expect)(n).toEqual([{type:t.ClearSignContextType.TRON_TOKEN,payload:f}])}),(0,e.it)("should return no context and not call CAL when the transaction holds no TRC10 transfer",async()=>{const n=await a.load({rawTransaction:T});(0,e.expect)(n).toEqual([]),(0,e.expect)(o.getTokenInfosPayload).not.toHaveBeenCalled()}),(0,e.it)("should return an error context when the token is unknown to CAL",async()=>{const n=new Error("not found");e.vi.spyOn(o,"getTokenInfosPayload").mockResolvedValue((0,d.Left)(n));const r=await a.load({rawTransaction:c});(0,e.expect)(r).toEqual([{type:t.ClearSignContextType.ERROR,error:n}])})})});
|
|
2
|
+
//# sourceMappingURL=TokenContextLoader.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/domain/TokenContextLoader.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\n\nimport { type TokenDataSource } from \"@/modules/tron/token/data/TokenDataSource\";\nimport { ClearSignContextType } from \"@/shared/model/ClearSignContext\";\n\nimport { TokenContextLoader } from \"./TokenContextLoader\";\n\nconst fromHex = (hex: string) =>\n Uint8Array.from(hex.match(/.{2}/g)!.map((byte) => parseInt(byte, 16)));\n\n// TransferAssetContract, asset_name \"1002000\".\nconst TRC10_TRANSFER = fromHex(\n \"0a023dce220895da42177db005074080d095ffbc315a75080212710a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e7472616374123b0a0731303032303030121541c8599111f29c1e1e061265b4af93ea1f274ad78a1a154114183f3bbca4ae9fc1de55b9bbe2d071942dc1a62087ad4b70a0fb91ffbc31\",\n);\n\n// Plain TRX TransferContract.\nconst TRX_TRANSFER = fromHex(\n \"0a023dce220895da42177db0050740d8e0a5feed2d522c43727970746f436861696e2d54726f6e5352204c6564676572205472616e73616374696f6e732054657374735a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a1541c8599111f29c1e1e061265b4af93ea1f274ad78a121541c8599111f29c1e1e061265b4af93ea1f274ad78a1880c2d72f709d94a2feed2d\",\n);\n\nconst PAYLOAD =\n \"0a0a426974546f7272656e7410061a46304402202e2502f36b00e57be785fc79ec4043abcdd4fdd1b58d737ce123599dffad2cb602201702c307f009d014a553503b499591558b3634ceee4c054c61cedd8aca94c02b\";\n\ndescribe(\"TokenContextLoader\", () => {\n let dataSource: TokenDataSource;\n let loader: TokenContextLoader;\n\n beforeEach(() => {\n vi.restoreAllMocks();\n dataSource = {\n getTokenInfosPayload: vi.fn(),\n } as unknown as TokenDataSource;\n loader = new TokenContextLoader(dataSource);\n });\n\n describe(\"canHandle\", () => {\n it(\"should handle a raw transaction when the token type is expected\", () => {\n expect(\n loader.canHandle({ rawTransaction: TRC10_TRANSFER }, [\n ClearSignContextType.TRON_TOKEN,\n ]),\n ).toBe(true);\n });\n\n it(\"should not handle it when the token type is not expected\", () => {\n expect(\n loader.canHandle({ rawTransaction: TRC10_TRANSFER }, [\n ClearSignContextType.ETHEREUM_TOKEN,\n ]),\n ).toBe(false);\n });\n\n it.each([\n [\"null\", null],\n [\"an empty object\", {}],\n [\"a hex string\", { rawTransaction: \"0a023dce\" }],\n [\"an empty transaction\", { rawTransaction: new Uint8Array() }],\n ])(\"should not handle %s\", (_label, input) => {\n expect(loader.canHandle(input, [ClearSignContextType.TRON_TOKEN])).toBe(\n false,\n );\n });\n });\n\n describe(\"load\", () => {\n it(\"should return the token context of a TRC10 transfer\", async () => {\n vi.spyOn(dataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Right(PAYLOAD),\n );\n\n const result = await loader.load({ rawTransaction: TRC10_TRANSFER });\n\n expect(dataSource.getTokenInfosPayload).toHaveBeenCalledWith({\n assetId: \"1002000\",\n });\n expect(result).toEqual([\n { type: ClearSignContextType.TRON_TOKEN, payload: PAYLOAD },\n ]);\n });\n\n it(\"should return no context and not call CAL when the transaction holds no TRC10 transfer\", async () => {\n const result = await loader.load({ rawTransaction: TRX_TRANSFER });\n\n expect(result).toEqual([]);\n expect(dataSource.getTokenInfosPayload).not.toHaveBeenCalled();\n });\n\n it(\"should return an error context when the token is unknown to CAL\", async () => {\n const error = new Error(\"not found\");\n vi.spyOn(dataSource, \"getTokenInfosPayload\").mockResolvedValue(\n Left(error),\n );\n\n const result = await loader.load({ rawTransaction: TRC10_TRANSFER });\n\n expect(result).toEqual([{ type: ClearSignContextType.ERROR, error }]);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAA4B,qBAC5BC,EAAqD,kBAGrDC,EAAqC,2CAErCC,EAAmC,gCAEnC,MAAMC,EAAWC,GACf,WAAW,KAAKA,EAAI,MAAM,OAAO,EAAG,IAAKC,GAAS,SAASA,EAAM,EAAE,CAAC,CAAC,EAGjEC,EAAiBH,EACrB,wSACF,EAGMI,EAAeJ,EACnB,0WACF,EAEMK,EACJ,kLAEF,YAAS,qBAAsB,IAAM,CACnC,IAAIC,EACAC,KAEJ,cAAW,IAAM,CACf,KAAG,gBAAgB,EACnBD,EAAa,CACX,qBAAsB,KAAG,GAAG,CAC9B,EACAC,EAAS,IAAI,qBAAmBD,CAAU,CAC5C,CAAC,KAED,YAAS,YAAa,IAAM,IAC1B,MAAG,kEAAmE,IAAM,IAC1E,UACEC,EAAO,UAAU,CAAE,eAAgBJ,CAAe,EAAG,CACnD,uBAAqB,UACvB,CAAC,CACH,EAAE,KAAK,EAAI,CACb,CAAC,KAED,MAAG,2DAA4D,IAAM,IACnE,UACEI,EAAO,UAAU,CAAE,eAAgBJ,CAAe,EAAG,CACnD,uBAAqB,cACvB,CAAC,CACH,EAAE,KAAK,EAAK,CACd,CAAC,EAED,KAAG,KAAK,CACN,CAAC,OAAQ,IAAI,EACb,CAAC,kBAAmB,CAAC,CAAC,EACtB,CAAC,eAAgB,CAAE,eAAgB,UAAW,CAAC,EAC/C,CAAC,uBAAwB,CAAE,eAAgB,IAAI,UAAa,CAAC,CAC/D,CAAC,EAAE,uBAAwB,CAACK,EAAQC,IAAU,IAC5C,UAAOF,EAAO,UAAUE,EAAO,CAAC,uBAAqB,UAAU,CAAC,CAAC,EAAE,KACjE,EACF,CACF,CAAC,CACH,CAAC,KAED,YAAS,OAAQ,IAAM,IACrB,MAAG,sDAAuD,SAAY,CACpE,KAAG,MAAMH,EAAY,sBAAsB,EAAE,qBAC3C,SAAMD,CAAO,CACf,EAEA,MAAMK,EAAS,MAAMH,EAAO,KAAK,CAAE,eAAgBJ,CAAe,CAAC,KAEnE,UAAOG,EAAW,oBAAoB,EAAE,qBAAqB,CAC3D,QAAS,SACX,CAAC,KACD,UAAOI,CAAM,EAAE,QAAQ,CACrB,CAAE,KAAM,uBAAqB,WAAY,QAASL,CAAQ,CAC5D,CAAC,CACH,CAAC,KAED,MAAG,yFAA0F,SAAY,CACvG,MAAMK,EAAS,MAAMH,EAAO,KAAK,CAAE,eAAgBH,CAAa,CAAC,KAEjE,UAAOM,CAAM,EAAE,QAAQ,CAAC,CAAC,KACzB,UAAOJ,EAAW,oBAAoB,EAAE,IAAI,iBAAiB,CAC/D,CAAC,KAED,MAAG,kEAAmE,SAAY,CAChF,MAAMK,EAAQ,IAAI,MAAM,WAAW,EACnC,KAAG,MAAML,EAAY,sBAAsB,EAAE,qBAC3C,QAAKK,CAAK,CACZ,EAEA,MAAMD,EAAS,MAAMH,EAAO,KAAK,CAAE,eAAgBJ,CAAe,CAAC,KAEnE,UAAOO,CAAM,EAAE,QAAQ,CAAC,CAAE,KAAM,uBAAqB,MAAO,MAAAC,CAAM,CAAC,CAAC,CACtE,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_purify_ts", "import_vitest", "import_ClearSignContext", "import_TokenContextLoader", "fromHex", "hex", "byte", "TRC10_TRANSFER", "TRX_TRANSFER", "PAYLOAD", "dataSource", "loader", "_label", "input", "result", "error"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var E=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var _=(e,r)=>{for(var n in r)E(e,n,{get:r[n],enumerable:!0})},c=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of o(r))!A.call(e,d)&&d!==n&&E(e,d,{get:()=>r[d],enumerable:!(t=T(r,d))||t.enumerable});return e};var s=e=>c(E({},"__esModule",{value:!0}),e);var N={};_(N,{parseTrc10AssetId:()=>R});module.exports=s(N);function a(e,r){let n=0,t=1;for(let d=0;d<10;d++){const i=e[r+d];if(i===void 0)return;if(n+=(i&127)*t,(i&128)===0)return{value:n,next:r+d+1};t*=128}}function I(e,r){const n=a(e,r);if(n===void 0)return;const t=Math.floor(n.value/8),d=n.value%8;switch(d){case 0:{const i=a(e,n.next);return i===void 0?void 0:{fieldNumber:t,wireType:d,value:i.value,next:i.next}}case 2:{const i=a(e,n.next);if(i===void 0)return;const u=i.next+i.value;return u>e.length?void 0:{fieldNumber:t,wireType:d,data:e.subarray(i.next,u),next:u}}case 1:case 5:{const i=n.next+(d===1?8:4);return i>e.length?void 0:{fieldNumber:t,wireType:d,next:i}}default:return}}function f(e,r){let n=0;for(;n<e.length;){const t=I(e,n);if(t===void 0)return;if(t.fieldNumber===r&&t.data!==void 0)return t.data;n=t.next}}function l(e,r){let n=0;for(;n<e.length;){const t=I(e,n);if(t===void 0)return;if(t.fieldNumber===r&&t.wireType===0)return t.value;n=t.next}}function R(e){const r=f(e,11);if(r===void 0||l(r,1)!==2)return;const n=f(r,2);if(n===void 0)return;const t=f(n,2);if(t===void 0)return;const d=f(t,1);if(!(d===void 0||d.length===0||!d.every(u=>u>=48&&u<=57)))return String.fromCharCode(...d)}0&&(module.exports={parseTrc10AssetId});
|
|
2
|
+
//# sourceMappingURL=parseTrc10AssetId.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/domain/parseTrc10AssetId.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Extracts the TRC10 asset id from a serialized Tron `Transaction.raw`.\n *\n * The asset id travels in the transaction itself, so a TRC10 transfer is\n * recognisable without the caller naming the token.\n *\n * Field numbers follow app-tron's `proto/core/Tron.proto` and\n * `proto/core/Contract.proto`.\n */\n\nconst CONTRACT_FIELD = 11; // Transaction.raw.contract\nconst CONTRACT_TYPE_FIELD = 1; // Transaction.Contract.type\nconst CONTRACT_PARAMETER_FIELD = 2; // Transaction.Contract.parameter\nconst ANY_VALUE_FIELD = 2; // google.protobuf.Any.value\nconst ASSET_NAME_FIELD = 1; // TransferAssetContract.asset_name\n\nconst TRANSFER_ASSET_CONTRACT = 2; // Transaction.Contract.ContractType\n\nconst WIRE_VARINT = 0;\nconst WIRE_64BIT = 1;\nconst WIRE_LENGTH_DELIMITED = 2;\nconst WIRE_32BIT = 5;\n\nconst MAX_VARINT_BYTES = 10;\nconst ASCII_ZERO = 0x30;\nconst ASCII_NINE = 0x39;\n\ntype Varint = { value: number; next: number };\n\ntype ProtobufField = {\n fieldNumber: number;\n wireType: number;\n data?: Uint8Array;\n value?: number;\n next: number;\n};\n\n/**\n * Values above 2^53 lose precision, which is harmless here: the only decoded\n * value ever compared is the contract type, and oversized varints (amounts,\n * timestamps) are read solely to know where the next field starts.\n */\nfunction readVarint(bytes: Uint8Array, offset: number): Varint | undefined {\n let value = 0;\n let shift = 1;\n for (let i = 0; i < MAX_VARINT_BYTES; i++) {\n const byte = bytes[offset + i];\n if (byte === undefined) return undefined;\n value += (byte & 0x7f) * shift;\n if ((byte & 0x80) === 0) return { value, next: offset + i + 1 };\n shift *= 128;\n }\n return undefined;\n}\n\nfunction readField(\n bytes: Uint8Array,\n offset: number,\n): ProtobufField | undefined {\n const key = readVarint(bytes, offset);\n if (key === undefined) return undefined;\n\n const fieldNumber = Math.floor(key.value / 8);\n const wireType = key.value % 8;\n\n switch (wireType) {\n case WIRE_VARINT: {\n const varint = readVarint(bytes, key.next);\n if (varint === undefined) return undefined;\n return { fieldNumber, wireType, value: varint.value, next: varint.next };\n }\n case WIRE_LENGTH_DELIMITED: {\n const length = readVarint(bytes, key.next);\n if (length === undefined) return undefined;\n const end = length.next + length.value;\n if (end > bytes.length) return undefined;\n return {\n fieldNumber,\n wireType,\n data: bytes.subarray(length.next, end),\n next: end,\n };\n }\n case WIRE_64BIT:\n case WIRE_32BIT: {\n const end = key.next + (wireType === WIRE_64BIT ? 8 : 4);\n if (end > bytes.length) return undefined;\n return { fieldNumber, wireType, next: end };\n }\n default:\n return undefined;\n }\n}\n\nfunction findLengthDelimited(\n bytes: Uint8Array,\n fieldNumber: number,\n): Uint8Array | undefined {\n let offset = 0;\n while (offset < bytes.length) {\n const field = readField(bytes, offset);\n if (field === undefined) return undefined;\n if (field.fieldNumber === fieldNumber && field.data !== undefined) {\n return field.data;\n }\n offset = field.next;\n }\n return undefined;\n}\n\nfunction findVarint(\n bytes: Uint8Array,\n fieldNumber: number,\n): number | undefined {\n let offset = 0;\n while (offset < bytes.length) {\n const field = readField(bytes, offset);\n if (field === undefined) return undefined;\n if (field.fieldNumber === fieldNumber && field.wireType === WIRE_VARINT) {\n return field.value;\n }\n offset = field.next;\n }\n return undefined;\n}\n\n/**\n * Returns the TRC10 asset id, or `undefined` when the transaction is not a\n * TRC10 transfer. Native TRX rides on the same contract with an `_` asset\n * name, and is rejected here along with any malformed payload.\n */\nexport function parseTrc10AssetId(\n rawTransaction: Uint8Array,\n): string | undefined {\n const contract = findLengthDelimited(rawTransaction, CONTRACT_FIELD);\n if (contract === undefined) return undefined;\n\n if (findVarint(contract, CONTRACT_TYPE_FIELD) !== TRANSFER_ASSET_CONTRACT) {\n return undefined;\n }\n\n const parameter = findLengthDelimited(contract, CONTRACT_PARAMETER_FIELD);\n if (parameter === undefined) return undefined;\n\n const value = findLengthDelimited(parameter, ANY_VALUE_FIELD);\n if (value === undefined) return undefined;\n\n const assetName = findLengthDelimited(value, ASSET_NAME_FIELD);\n if (assetName === undefined || assetName.length === 0) return undefined;\n\n const isAssetId = assetName.every(\n (byte) => byte >= ASCII_ZERO && byte <= ASCII_NINE,\n );\n if (!isAssetId) return undefined;\n\n return String.fromCharCode(...assetName);\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GA0CA,SAASI,EAAWC,EAAmBC,EAAoC,CACzE,IAAIC,EAAQ,EACRC,EAAQ,EACZ,QAASC,EAAI,EAAGA,EAAI,GAAkBA,IAAK,CACzC,MAAMC,EAAOL,EAAMC,EAASG,CAAC,EAC7B,GAAIC,IAAS,OAAW,OAExB,GADAH,IAAUG,EAAO,KAAQF,GACpBE,EAAO,OAAU,EAAG,MAAO,CAAE,MAAAH,EAAO,KAAMD,EAASG,EAAI,CAAE,EAC9DD,GAAS,GACX,CAEF,CAEA,SAASG,EACPN,EACAC,EAC2B,CAC3B,MAAMM,EAAMR,EAAWC,EAAOC,CAAM,EACpC,GAAIM,IAAQ,OAAW,OAEvB,MAAMC,EAAc,KAAK,MAAMD,EAAI,MAAQ,CAAC,EACtCE,EAAWF,EAAI,MAAQ,EAE7B,OAAQE,EAAU,CAChB,IAAK,GAAa,CAChB,MAAMC,EAASX,EAAWC,EAAOO,EAAI,IAAI,EACzC,OAAIG,IAAW,OAAW,OACnB,CAAE,YAAAF,EAAa,SAAAC,EAAU,MAAOC,EAAO,MAAO,KAAMA,EAAO,IAAK,CACzE,CACA,IAAK,GAAuB,CAC1B,MAAMC,EAASZ,EAAWC,EAAOO,EAAI,IAAI,EACzC,GAAII,IAAW,OAAW,OAC1B,MAAMC,EAAMD,EAAO,KAAOA,EAAO,MACjC,OAAIC,EAAMZ,EAAM,OAAQ,OACjB,CACL,YAAAQ,EACA,SAAAC,EACA,KAAMT,EAAM,SAASW,EAAO,KAAMC,CAAG,EACrC,KAAMA,CACR,CACF,CACA,IAAK,GACL,IAAK,GAAY,CACf,MAAMA,EAAML,EAAI,MAAQE,IAAa,EAAa,EAAI,GACtD,OAAIG,EAAMZ,EAAM,OAAQ,OACjB,CAAE,YAAAQ,EAAa,SAAAC,EAAU,KAAMG,CAAI,CAC5C,CACA,QACE,MACJ,CACF,CAEA,SAASC,EACPb,EACAQ,EACwB,CACxB,IAAIP,EAAS,EACb,KAAOA,EAASD,EAAM,QAAQ,CAC5B,MAAMc,EAAQR,EAAUN,EAAOC,CAAM,EACrC,GAAIa,IAAU,OAAW,OACzB,GAAIA,EAAM,cAAgBN,GAAeM,EAAM,OAAS,OACtD,OAAOA,EAAM,KAEfb,EAASa,EAAM,IACjB,CAEF,CAEA,SAASC,EACPf,EACAQ,EACoB,CACpB,IAAIP,EAAS,EACb,KAAOA,EAASD,EAAM,QAAQ,CAC5B,MAAMc,EAAQR,EAAUN,EAAOC,CAAM,EACrC,GAAIa,IAAU,OAAW,OACzB,GAAIA,EAAM,cAAgBN,GAAeM,EAAM,WAAa,EAC1D,OAAOA,EAAM,MAEfb,EAASa,EAAM,IACjB,CAEF,CAOO,SAASE,EACdC,EACoB,CACpB,MAAMC,EAAWL,EAAoBI,EAAgB,EAAc,EAGnE,GAFIC,IAAa,QAEbH,EAAWG,EAAU,CAAmB,IAAM,EAChD,OAGF,MAAMC,EAAYN,EAAoBK,EAAU,CAAwB,EACxE,GAAIC,IAAc,OAAW,OAE7B,MAAMjB,EAAQW,EAAoBM,EAAW,CAAe,EAC5D,GAAIjB,IAAU,OAAW,OAEzB,MAAMkB,EAAYP,EAAoBX,EAAO,CAAgB,EAM7D,GALI,EAAAkB,IAAc,QAAaA,EAAU,SAAW,GAKhD,CAHcA,EAAU,MACzBf,GAASA,GAAQ,IAAcA,GAAQ,EAC1C,GAGA,OAAO,OAAO,aAAa,GAAGe,CAAS,CACzC",
|
|
6
|
+
"names": ["parseTrc10AssetId_exports", "__export", "parseTrc10AssetId", "__toCommonJS", "readVarint", "bytes", "offset", "value", "shift", "i", "byte", "readField", "key", "fieldNumber", "wireType", "varint", "length", "end", "findLengthDelimited", "field", "findVarint", "parseTrc10AssetId", "rawTransaction", "contract", "parameter", "assetName"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("vitest"),f=require("./parseTrc10AssetId");const a=d=>Uint8Array.from(d.match(/.{2}/g).map(n=>parseInt(n,16))),c="0a023dce220895da42177db005074080d095ffbc315a75080212710a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e7472616374123b0a0731303032303030121541c8599111f29c1e1e061265b4af93ea1f274ad78a1a154114183f3bbca4ae9fc1de55b9bbe2d071942dc1a62087ad4b70a0fb91ffbc31",t="0a023dce220895da42177db005074080d095ffbc315aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541c8599111f29c1e1e061265b4af93ea1f274ad78a121541a614f803b6fd780986a42c78ec9c7f77e6ded13c2244a9059cbb00000000000000000000000014183f3bbca4ae9fc1de55b9bbe2d071942dc1a60000000000000000000000000000000000000000000000000000000000bc614e70a0fb91ffbc31900180c2d72f",r="0a023dce220895da42177db0050740d8e0a5feed2d522c43727970746f436861696e2d54726f6e5352204c6564676572205472616e73616374696f6e732054657374735a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a1541c8599111f29c1e1e061265b4af93ea1f274ad78a121541c8599111f29c1e1e061265b4af93ea1f274ad78a1880c2d72f709d94a2feed2d",b="0a023dce220895da42177db005074080d095ffbc315a6e0802126a0a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e747261637412340a015f121541c8599111f29c1e1e061265b4af93ea1f274ad78a1a154114183f3bbca4ae9fc1de55b9bbe2d071942dc1a620e80770a0fb91ffbc31";(0,e.describe)("parseTrc10AssetId",()=>{(0,e.it)("should return the asset id of a TRC10 transfer",()=>{(0,e.expect)((0,f.parseTrc10AssetId)(a(c))).toBe("1002000")}),(0,e.it)("should return undefined for a TRC20 transfer",()=>{(0,e.expect)((0,f.parseTrc10AssetId)(a(t))).toBeUndefined()}),(0,e.it)("should return undefined for a plain TRX transfer",()=>{(0,e.expect)((0,f.parseTrc10AssetId)(a(r))).toBeUndefined()}),(0,e.it)("should return undefined when the asset name is the native TRX marker",()=>{(0,e.expect)((0,f.parseTrc10AssetId)(a(b))).toBeUndefined()}),(0,e.it)("should return undefined for an empty transaction",()=>{(0,e.expect)((0,f.parseTrc10AssetId)(new Uint8Array)).toBeUndefined()}),(0,e.it)("should return undefined for a truncated transaction",()=>{const d=a(c).subarray(0,40);(0,e.expect)((0,f.parseTrc10AssetId)(d)).toBeUndefined()}),(0,e.it)("should return undefined for bytes that are not protobuf",()=>{(0,e.expect)((0,f.parseTrc10AssetId)(a("ffffffffffffffffffff"))).toBeUndefined()})});
|
|
2
|
+
//# sourceMappingURL=parseTrc10AssetId.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/tron/token/domain/parseTrc10AssetId.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\n\nimport { parseTrc10AssetId } from \"./parseTrc10AssetId\";\n\nconst fromHex = (hex: string) =>\n Uint8Array.from(hex.match(/.{2}/g)!.map((byte) => parseInt(byte, 16)));\n\n// TransferAssetContract, asset_name \"1002000\" (BitTorrent), amount 1234567.\nconst TRC10_TRANSFER =\n \"0a023dce220895da42177db005074080d095ffbc315a75080212710a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e7472616374123b0a0731303032303030121541c8599111f29c1e1e061265b4af93ea1f274ad78a1a154114183f3bbca4ae9fc1de55b9bbe2d071942dc1a62087ad4b70a0fb91ffbc31\";\n\n// TriggerSmartContract calling transfer(address,uint256) on USDT.\nconst TRC20_TRANSFER =\n \"0a023dce220895da42177db005074080d095ffbc315aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541c8599111f29c1e1e061265b4af93ea1f274ad78a121541a614f803b6fd780986a42c78ec9c7f77e6ded13c2244a9059cbb00000000000000000000000014183f3bbca4ae9fc1de55b9bbe2d071942dc1a60000000000000000000000000000000000000000000000000000000000bc614e70a0fb91ffbc31900180c2d72f\";\n\n// Plain TRX TransferContract, from the hw-app-trx vector.\nconst TRX_TRANSFER =\n \"0a023dce220895da42177db0050740d8e0a5feed2d522c43727970746f436861696e2d54726f6e5352204c6564676572205472616e73616374696f6e732054657374735a68080112640a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412330a1541c8599111f29c1e1e061265b4af93ea1f274ad78a121541c8599111f29c1e1e061265b4af93ea1f274ad78a1880c2d72f709d94a2feed2d\";\n\n// TransferAssetContract whose asset_name is \"_\", the native-TRX marker.\nconst NATIVE_TRX_ASSET =\n \"0a023dce220895da42177db005074080d095ffbc315a6e0802126a0a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e747261637412340a015f121541c8599111f29c1e1e061265b4af93ea1f274ad78a1a154114183f3bbca4ae9fc1de55b9bbe2d071942dc1a620e80770a0fb91ffbc31\";\n\ndescribe(\"parseTrc10AssetId\", () => {\n it(\"should return the asset id of a TRC10 transfer\", () => {\n expect(parseTrc10AssetId(fromHex(TRC10_TRANSFER))).toBe(\"1002000\");\n });\n\n it(\"should return undefined for a TRC20 transfer\", () => {\n expect(parseTrc10AssetId(fromHex(TRC20_TRANSFER))).toBeUndefined();\n });\n\n it(\"should return undefined for a plain TRX transfer\", () => {\n expect(parseTrc10AssetId(fromHex(TRX_TRANSFER))).toBeUndefined();\n });\n\n it(\"should return undefined when the asset name is the native TRX marker\", () => {\n expect(parseTrc10AssetId(fromHex(NATIVE_TRX_ASSET))).toBeUndefined();\n });\n\n it(\"should return undefined for an empty transaction\", () => {\n expect(parseTrc10AssetId(new Uint8Array())).toBeUndefined();\n });\n\n it(\"should return undefined for a truncated transaction\", () => {\n const truncated = fromHex(TRC10_TRANSFER).subarray(0, 40);\n expect(parseTrc10AssetId(truncated)).toBeUndefined();\n });\n\n it(\"should return undefined for bytes that are not protobuf\", () => {\n expect(parseTrc10AssetId(fromHex(\"ffffffffffffffffffff\"))).toBeUndefined();\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAAqC,kBAErCC,EAAkC,+BAElC,MAAMC,EAAWC,GACf,WAAW,KAAKA,EAAI,MAAM,OAAO,EAAG,IAAKC,GAAS,SAASA,EAAM,EAAE,CAAC,CAAC,EAGjEC,EACJ,ySAGIC,EACJ,yaAGIC,EACJ,2WAGIC,EACJ,8RAEF,YAAS,oBAAqB,IAAM,IAClC,MAAG,iDAAkD,IAAM,IACzD,aAAO,qBAAkBN,EAAQG,CAAc,CAAC,CAAC,EAAE,KAAK,SAAS,CACnE,CAAC,KAED,MAAG,+CAAgD,IAAM,IACvD,aAAO,qBAAkBH,EAAQI,CAAc,CAAC,CAAC,EAAE,cAAc,CACnE,CAAC,KAED,MAAG,mDAAoD,IAAM,IAC3D,aAAO,qBAAkBJ,EAAQK,CAAY,CAAC,CAAC,EAAE,cAAc,CACjE,CAAC,KAED,MAAG,uEAAwE,IAAM,IAC/E,aAAO,qBAAkBL,EAAQM,CAAgB,CAAC,CAAC,EAAE,cAAc,CACrE,CAAC,KAED,MAAG,mDAAoD,IAAM,IAC3D,aAAO,qBAAkB,IAAI,UAAY,CAAC,EAAE,cAAc,CAC5D,CAAC,KAED,MAAG,sDAAuD,IAAM,CAC9D,MAAMC,EAAYP,EAAQG,CAAc,EAAE,SAAS,EAAG,EAAE,KACxD,aAAO,qBAAkBI,CAAS,CAAC,EAAE,cAAc,CACrD,CAAC,KAED,MAAG,0DAA2D,IAAM,IAClE,aAAO,qBAAkBP,EAAQ,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAC3E,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_vitest", "import_parseTrc10AssetId", "fromHex", "hex", "byte", "TRC10_TRANSFER", "TRC20_TRANSFER", "TRX_TRANSFER", "NATIVE_TRX_ASSET", "truncated"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var a=(c,m)=>{for(var o in m)p(c,o,{get:m[o],enumerable:!0})},b=(c,m,o,s)=>{if(m&&typeof m=="object"||typeof m=="function")for(let r of S(m))!T.call(c,r)&&r!==o&&p(c,r,{get:()=>m[r],enumerable:!(s=E(m,r))||s.enumerable});return c};var f=c=>b(p({},"__esModule",{value:!0}),c);var g={};a(g,{ContextModuleChainID:()=>u});module.exports=f(g);var u=(r=>(r.Ethereum="ethereum",r.Solana="solana",r.Concordium="concordium",r.Tron="tron",r))(u||{});0&&(module.exports={ContextModuleChainID});
|
|
2
2
|
//# sourceMappingURL=ContextModuleChainID.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/shared/domain/ContextModuleChainID.ts"],
|
|
4
|
-
"sourcesContent": ["export enum ContextModuleChainID {\n Ethereum = \"ethereum\",\n Solana = \"solana\",\n Concordium = \"concordium\",\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAO,IAAKE,OACVA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,WAAa,
|
|
4
|
+
"sourcesContent": ["export enum ContextModuleChainID {\n Ethereum = \"ethereum\",\n Solana = \"solana\",\n Concordium = \"concordium\",\n Tron = \"tron\",\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAAO,IAAKE,OACVA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,WAAa,aACbA,EAAA,KAAO,OAJGA,OAAA",
|
|
6
6
|
"names": ["ContextModuleChainID_exports", "__export", "ContextModuleChainID", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var u=(r,E)=>{for(var a in E)o(r,a,{get:E[a],enumerable:!0})},A=(r,E,a,t)=>{if(E&&typeof E=="object"||typeof E=="function")for(let s of O(E))!_.call(r,s)&&s!==a&&o(r,s,{get:()=>E[s],enumerable:!(t=c(E,s))||t.enumerable});return r};var T=r=>A(o({},"__esModule",{value:!0}),r);var n={};u(n,{ClearSignContextType:()=>N});module.exports=T(n);var N=(e=>(e.ERROR="error",e.CONCORDIUM_ACCOUNT_OWNERSHIP="concordiumAccountOwnership",e.ETHEREUM_TOKEN="ethereumToken",e.ETHEREUM_NFT="ethereumNft",e.ETHEREUM_TRUSTED_NAME="ethereumTrustedName",e.ETHEREUM_PLUGIN="ethereumPlugin",e.ETHEREUM_EXTERNAL_PLUGIN="ethereumExternalPlugin",e.ETHEREUM_TRANSACTION_INFO="ethereumTransactionInfo",e.ETHEREUM_PROXY_INFO="ethereumProxyInfo",e.ETHEREUM_ENUM="ethereumEnum",e.ETHEREUM_TRANSACTION_FIELD_DESCRIPTION="ethereumTransactionFieldDescription",e.ETHEREUM_TRANSACTION_CHECK="ethereumTransactionCheck",e.ETHEREUM_DYNAMIC_NETWORK="ethereumDynamicNetwork",e.ETHEREUM_DYNAMIC_NETWORK_ICON="ethereumDynamicNetworkIcon",e.ETHEREUM_SAFE="ethereumSafe",e.ETHEREUM_SIGNER="ethereumSigner",e.ETHEREUM_GATED_SIGNING="ethereumGatedSigning",e.SOLANA_TOKEN="solanaToken",e.SOLANA_LIFI="solanaLifi",e.SOLANA_TRUSTED_NAME="solanaTrustedName",e.SOLANA_BASIC_TRUSTED_NAME="solanaBasicTrustedName",e.SOLANA_TRANSACTION_CHECK="solanaTransactionCheck",e.SOLANA_INSTRUCTION_INFO="solanaInstructionInfo",e.SOLANA_ENUM_VARIANT="solanaEnumVariant",e.SOLANA_TOKEN_INFO="solanaTokenInfo",e.SOLANA_TOKEN_ACCOUNT_STATE="solanaTokenAccountState",e.SOLANA_ALT_RESOLUTION="solanaAltResolution",e.TRON_TOKEN="tronToken",e))(N||{});0&&(module.exports={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 EthereumPayloadOverrides } from \"@/modules/ethereum/model/EthereumClearSignContext\";\nimport { type PkiCertificate } from \"@/modules/multichain/pki/model/PkiCertificate\";\nimport { type SolanaPayloadOverrides } from \"@/modules/solana/model/SolanaClearSignContext\";\n\nexport enum ClearSignContextType {\n ERROR = \"error\",\n CONCORDIUM_ACCOUNT_OWNERSHIP = \"concordiumAccountOwnership\",\n ETHEREUM_TOKEN = \"ethereumToken\",\n ETHEREUM_NFT = \"ethereumNft\",\n ETHEREUM_TRUSTED_NAME = \"ethereumTrustedName\",\n ETHEREUM_PLUGIN = \"ethereumPlugin\",\n ETHEREUM_EXTERNAL_PLUGIN = \"ethereumExternalPlugin\",\n ETHEREUM_TRANSACTION_INFO = \"ethereumTransactionInfo\",\n ETHEREUM_PROXY_INFO = \"ethereumProxyInfo\",\n ETHEREUM_ENUM = \"ethereumEnum\",\n ETHEREUM_TRANSACTION_FIELD_DESCRIPTION = \"ethereumTransactionFieldDescription\",\n ETHEREUM_TRANSACTION_CHECK = \"ethereumTransactionCheck\",\n ETHEREUM_DYNAMIC_NETWORK = \"ethereumDynamicNetwork\",\n ETHEREUM_DYNAMIC_NETWORK_ICON = \"ethereumDynamicNetworkIcon\",\n ETHEREUM_SAFE = \"ethereumSafe\",\n ETHEREUM_SIGNER = \"ethereumSigner\",\n ETHEREUM_GATED_SIGNING = \"ethereumGatedSigning\",\n SOLANA_TOKEN = \"solanaToken\",\n SOLANA_LIFI = \"solanaLifi\",\n SOLANA_TRUSTED_NAME = \"solanaTrustedName\",\n SOLANA_BASIC_TRUSTED_NAME = \"solanaBasicTrustedName\",\n SOLANA_TRANSACTION_CHECK = \"solanaTransactionCheck\",\n SOLANA_INSTRUCTION_INFO = \"solanaInstructionInfo\",\n SOLANA_ENUM_VARIANT = \"solanaEnumVariant\",\n SOLANA_TOKEN_INFO = \"solanaTokenInfo\",\n SOLANA_TOKEN_ACCOUNT_STATE = \"solanaTokenAccountState\",\n SOLANA_ALT_RESOLUTION = \"solanaAltResolution\",\n}\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\n/**\n * Base payload shape shared by every success context. Chain modules extend\n * this via PayloadOverrides for variants that carry typed payloads.\n */\nexport type ClearSignContextSuccessBase = {\n payload: string;\n certificate?: PkiCertificate;\n};\n\ntype ClearSignContextSuccessPayloadsBase = {\n [K in ClearSignContextSuccessType]: ClearSignContextSuccessBase;\n};\n\n// Chain modules contribute typed-payload overrides. This file is the\n// integration boundary that assembles them into the cross-chain union.\ntype ClearSignContextSuccessPayloadOverrides = EthereumPayloadOverrides &\n SolanaPayloadOverrides;\n\ntype ClearSignContextSuccessPayloads = Omit<\n ClearSignContextSuccessPayloadsBase,\n keyof ClearSignContextSuccessPayloadOverrides\n> &\n ClearSignContextSuccessPayloadOverrides;\n\nexport type ClearSignContextSuccess<\n T extends ClearSignContextSuccessType = ClearSignContextSuccessType,\n> = T extends ClearSignContextSuccessType\n ? { type: T } & ClearSignContextSuccessPayloads[T]\n : never;\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,MAAQ,QACRA,EAAA,6BAA+B,6BAC/BA,EAAA,eAAiB,gBACjBA,EAAA,aAAe,cACfA,EAAA,sBAAwB,sBACxBA,EAAA,gBAAkB,iBAClBA,EAAA,yBAA2B,yBAC3BA,EAAA,0BAA4B,0BAC5BA,EAAA,oBAAsB,oBACtBA,EAAA,cAAgB,eAChBA,EAAA,uCAAyC,sCACzCA,EAAA,2BAA6B,2BAC7BA,EAAA,yBAA2B,yBAC3BA,EAAA,8BAAgC,6BAChCA,EAAA,cAAgB,eAChBA,EAAA,gBAAkB,iBAClBA,EAAA,uBAAyB,uBACzBA,EAAA,aAAe,cACfA,EAAA,YAAc,aACdA,EAAA,oBAAsB,oBACtBA,EAAA,0BAA4B,yBAC5BA,EAAA,yBAA2B,yBAC3BA,EAAA,wBAA0B,wBAC1BA,EAAA,oBAAsB,oBACtBA,EAAA,kBAAoB,kBACpBA,EAAA,2BAA6B,0BAC7BA,EAAA,sBAAwB,
|
|
4
|
+
"sourcesContent": ["import { type EthereumPayloadOverrides } from \"@/modules/ethereum/model/EthereumClearSignContext\";\nimport { type PkiCertificate } from \"@/modules/multichain/pki/model/PkiCertificate\";\nimport { type SolanaPayloadOverrides } from \"@/modules/solana/model/SolanaClearSignContext\";\n\nexport enum ClearSignContextType {\n ERROR = \"error\",\n CONCORDIUM_ACCOUNT_OWNERSHIP = \"concordiumAccountOwnership\",\n ETHEREUM_TOKEN = \"ethereumToken\",\n ETHEREUM_NFT = \"ethereumNft\",\n ETHEREUM_TRUSTED_NAME = \"ethereumTrustedName\",\n ETHEREUM_PLUGIN = \"ethereumPlugin\",\n ETHEREUM_EXTERNAL_PLUGIN = \"ethereumExternalPlugin\",\n ETHEREUM_TRANSACTION_INFO = \"ethereumTransactionInfo\",\n ETHEREUM_PROXY_INFO = \"ethereumProxyInfo\",\n ETHEREUM_ENUM = \"ethereumEnum\",\n ETHEREUM_TRANSACTION_FIELD_DESCRIPTION = \"ethereumTransactionFieldDescription\",\n ETHEREUM_TRANSACTION_CHECK = \"ethereumTransactionCheck\",\n ETHEREUM_DYNAMIC_NETWORK = \"ethereumDynamicNetwork\",\n ETHEREUM_DYNAMIC_NETWORK_ICON = \"ethereumDynamicNetworkIcon\",\n ETHEREUM_SAFE = \"ethereumSafe\",\n ETHEREUM_SIGNER = \"ethereumSigner\",\n ETHEREUM_GATED_SIGNING = \"ethereumGatedSigning\",\n SOLANA_TOKEN = \"solanaToken\",\n SOLANA_LIFI = \"solanaLifi\",\n SOLANA_TRUSTED_NAME = \"solanaTrustedName\",\n SOLANA_BASIC_TRUSTED_NAME = \"solanaBasicTrustedName\",\n SOLANA_TRANSACTION_CHECK = \"solanaTransactionCheck\",\n SOLANA_INSTRUCTION_INFO = \"solanaInstructionInfo\",\n SOLANA_ENUM_VARIANT = \"solanaEnumVariant\",\n SOLANA_TOKEN_INFO = \"solanaTokenInfo\",\n SOLANA_TOKEN_ACCOUNT_STATE = \"solanaTokenAccountState\",\n SOLANA_ALT_RESOLUTION = \"solanaAltResolution\",\n TRON_TOKEN = \"tronToken\",\n}\n\nexport type ClearSignContextSuccessType = Exclude<\n ClearSignContextType,\n ClearSignContextType.ERROR\n>;\n\n/**\n * Base payload shape shared by every success context. Chain modules extend\n * this via PayloadOverrides for variants that carry typed payloads.\n */\nexport type ClearSignContextSuccessBase = {\n payload: string;\n certificate?: PkiCertificate;\n};\n\ntype ClearSignContextSuccessPayloadsBase = {\n [K in ClearSignContextSuccessType]: ClearSignContextSuccessBase;\n};\n\n// Chain modules contribute typed-payload overrides. This file is the\n// integration boundary that assembles them into the cross-chain union.\ntype ClearSignContextSuccessPayloadOverrides = EthereumPayloadOverrides &\n SolanaPayloadOverrides;\n\ntype ClearSignContextSuccessPayloads = Omit<\n ClearSignContextSuccessPayloadsBase,\n keyof ClearSignContextSuccessPayloadOverrides\n> &\n ClearSignContextSuccessPayloadOverrides;\n\nexport type ClearSignContextSuccess<\n T extends ClearSignContextSuccessType = ClearSignContextSuccessType,\n> = T extends ClearSignContextSuccessType\n ? { type: T } & ClearSignContextSuccessPayloads[T]\n : never;\n\nexport type ClearSignContextError = {\n type: ClearSignContextType.ERROR;\n error: Error;\n};\n\nexport type ClearSignContext = ClearSignContextSuccess | ClearSignContextError;\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GAIO,IAAKE,OACVA,EAAA,MAAQ,QACRA,EAAA,6BAA+B,6BAC/BA,EAAA,eAAiB,gBACjBA,EAAA,aAAe,cACfA,EAAA,sBAAwB,sBACxBA,EAAA,gBAAkB,iBAClBA,EAAA,yBAA2B,yBAC3BA,EAAA,0BAA4B,0BAC5BA,EAAA,oBAAsB,oBACtBA,EAAA,cAAgB,eAChBA,EAAA,uCAAyC,sCACzCA,EAAA,2BAA6B,2BAC7BA,EAAA,yBAA2B,yBAC3BA,EAAA,8BAAgC,6BAChCA,EAAA,cAAgB,eAChBA,EAAA,gBAAkB,iBAClBA,EAAA,uBAAyB,uBACzBA,EAAA,aAAe,cACfA,EAAA,YAAc,aACdA,EAAA,oBAAsB,oBACtBA,EAAA,0BAA4B,yBAC5BA,EAAA,yBAA2B,yBAC3BA,EAAA,wBAA0B,wBAC1BA,EAAA,oBAAsB,oBACtBA,EAAA,kBAAoB,kBACpBA,EAAA,2BAA6B,0BAC7BA,EAAA,sBAAwB,sBACxBA,EAAA,WAAa,YA5BHA,OAAA",
|
|
6
6
|
"names": ["ClearSignContext_exports", "__export", "ClearSignContextType", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/esm/package.json
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"license": "Apache-2.0",
|
|
36
36
|
"name": "@ledgerhq/context-module",
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@ledgerhq/device-management-kit": "
|
|
38
|
+
"@ledgerhq/device-management-kit": "workspace:^"
|
|
39
39
|
},
|
|
40
40
|
"private": false,
|
|
41
41
|
"repository": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
|
|
59
59
|
"watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
|
|
60
60
|
},
|
|
61
|
-
"version": "2.
|
|
61
|
+
"version": "2.6.0"
|
|
62
62
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{makeContainer as g}from"./di";import{accountOwnershipTypes as x}from"./modules/concordium/account-ownership/di/accountOwnershipTypes";import{calldataTypes as u}from"./modules/ethereum/calldata/di/calldataTypes";import{dynamicNetworkTypes as f}from"./modules/ethereum/dynamic-network/di/dynamicNetworkTypes";import{externalPluginTypes as L}from"./modules/ethereum/external-plugin/di/externalPluginTypes";import{gatedSigningTypes as p}from"./modules/ethereum/gated-signing/di/gatedSigningTypes";import{nftTypes as l}from"./modules/ethereum/nft/di/nftTypes";import{proxyTypes as y}from"./modules/ethereum/proxy/di/proxyTypes";import{safeTypes as h}from"./modules/ethereum/safe/di/safeTypes";import{tokenTypes as m}from"./modules/ethereum/token/di/tokenTypes";import{trustedNameTypes as C}from"./modules/ethereum/trusted-name/di/trustedNameTypes";import{typedDataTypes as
|
|
1
|
+
import{makeContainer as g}from"./di";import{accountOwnershipTypes as x}from"./modules/concordium/account-ownership/di/accountOwnershipTypes";import{calldataTypes as u}from"./modules/ethereum/calldata/di/calldataTypes";import{dynamicNetworkTypes as f}from"./modules/ethereum/dynamic-network/di/dynamicNetworkTypes";import{externalPluginTypes as L}from"./modules/ethereum/external-plugin/di/externalPluginTypes";import{gatedSigningTypes as p}from"./modules/ethereum/gated-signing/di/gatedSigningTypes";import{nftTypes as l}from"./modules/ethereum/nft/di/nftTypes";import{proxyTypes as y}from"./modules/ethereum/proxy/di/proxyTypes";import{safeTypes as h}from"./modules/ethereum/safe/di/safeTypes";import{tokenTypes as m}from"./modules/ethereum/token/di/tokenTypes";import{trustedNameTypes as C}from"./modules/ethereum/trusted-name/di/trustedNameTypes";import{typedDataTypes as T}from"./modules/ethereum/typed-data/di/typedDataTypes";import{reporterTypes as c}from"./modules/multichain/reporter/di/reporterTypes";import{transactionCheckTypes as s}from"./modules/multichain/transaction-check/di/transactionCheckTypes";import{altResolutionTypes as _}from"./modules/solana/alt-resolution/di/altResolutionTypes";import{enumVariantTypes as S}from"./modules/solana/enum-variant/di/enumVariantTypes";import{instructionInfoTypes as R}from"./modules/solana/instruction-info/di/instructionInfoTypes";import{lifiTypes as D}from"./modules/solana/lifi/di/lifiTypes";import{ownerInfoTypes as k}from"./modules/solana/owner-info/di/ownerInfoTypes";import{tokenTypes as v}from"./modules/solana/token/di/tokenTypes";import{tokenAccountStateTypes as F}from"./modules/solana/token-account-state/di/tokenAccountStateTypes";import{tokenInfoTypes as w}from"./modules/solana/token-info/di/tokenInfoTypes";import{solanaTrustedNameTypes as P}from"./modules/solana/trusted-name/di/trustedNameTypes";import{tokenTypes as B}from"./modules/tron/token/di/tokenTypes";import{ContextModuleChainID as o}from"./shared/domain/ContextModuleChainID";import{ClearSignContextType as i}from"./shared/model/ClearSignContext";class ie{_container;_config;_loaders;_typedDataLoader;_fieldLoaders;_blindSigningReporter;_signReporter;constructor(e){this._config=e,this._container=g({config:e}),this._loaders=e.defaultLoaders?this._getDefaultLoaders():[],this._loaders.push(...e.customLoaders),this._fieldLoaders=e.defaultFieldLoaders?this._getDefaultFieldLoaders():[],this._fieldLoaders.push(...e.customFieldLoaders),this._typedDataLoader=e.customTypedDataLoader??this._getDefaultTypedDataLoader(),this._blindSigningReporter=e.customBlindSigningReporter??this._getBlindSigningReporter(),this._signReporter=null}_getDefaultFieldLoaders(){return this._config.chain!==o.Ethereum?[]:[this._container.get(l.NftContextFieldLoader),this._container.get(m.TokenContextFieldLoader),this._container.get(C.TrustedNameContextFieldLoader),this._container.get(y.ProxyContextFieldLoader)]}_getDefaultLoaders(){const{chain:e}=this._config;switch(e){case o.Ethereum:return[this._container.get(L.ExternalPluginContextLoader),this._container.get(C.TrustedNameContextLoader),this._container.get(l.NftContextLoader),this._container.get(m.TokenContextLoader),this._container.get(u.CalldataContextLoader),this._container.get(f.DynamicNetworkContextLoader),this._container.get(h.SafeAddressLoader),this._container.get(p.GatedSigningContextLoader),this._container.get(p.GatedSigningTypedDataContextLoader),this._container.get(s.TransactionCheckLoader),this._container.get(s.TypedDataCheckLoader)];case o.Solana:return[this._container.get(v.TokenContextLoader),this._container.get(D.LifiContextLoader),this._container.get(k.OwnerInfoContextLoader),this._container.get(s.TransactionCheckLoader),this._container.get(R.InstructionInfoContextLoader),this._container.get(S.EnumVariantContextLoader),this._container.get(w.TokenInfoContextLoader),this._container.get(F.TokenAccountStateContextLoader),this._container.get(_.AltResolutionContextLoader),this._container.get(P.SolanaTrustedNameContextLoader)];case o.Concordium:return[this._container.get(x.AccountOwnershipContextLoader)];case o.Tron:return[this._container.get(B.TokenContextLoader)];default:{const t=e;return[]}}}_getDefaultTypedDataLoader(){return this._config.chain!==o.Ethereum?{load:()=>Promise.reject(new Error("[ContextModule] getTypedDataFilters is not supported for this chain"))}:this._container.get(T.TypedDataContextLoader)}_getBlindSigningReporter(){return this._container.isBound(c.BlindSigningReporter)?this._container.get(c.BlindSigningReporter):null}async getContexts(e,t){const r=Object.values(i),a=this._loaders.filter(d=>d.canHandle(e,t??r)).map(d=>d.load(e));return(await Promise.all(a)).flat()}async getFieldContext(e,t){const r=this._fieldLoaders.filter(n=>n.canHandle(e,t));if(r.length===0)return Promise.resolve({type:i.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)});for(const n of r){const a=await n.loadField(e);if(a.type!==i.ERROR)return a}return{type:i.ERROR,error:new Error(`Loader not found for field: ${e} and expected type: ${t}`)}}async getTypedDataFilters(e){return this._typedDataLoader.load(e)}async report(e){await this._blindSigningReporter?.report(e)}async signReport(e){await this._signReporter?.report(e)}}export{ie 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\";\n\nimport {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { type ContextModule } from \"@/ContextModule\";\nimport { makeContainer } from \"@/di\";\nimport { accountOwnershipTypes } from \"@/modules/concordium/account-ownership/di/accountOwnershipTypes\";\nimport { calldataTypes } from \"@/modules/ethereum/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/modules/ethereum/dynamic-network/di/dynamicNetworkTypes\";\nimport { externalPluginTypes } from \"@/modules/ethereum/external-plugin/di/externalPluginTypes\";\nimport { gatedSigningTypes } from \"@/modules/ethereum/gated-signing/di/gatedSigningTypes\";\nimport type { TypedDataClearSignContext } from \"@/modules/ethereum/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/modules/ethereum/model/TypedDataContext\";\nimport { nftTypes } from \"@/modules/ethereum/nft/di/nftTypes\";\nimport { proxyTypes } from \"@/modules/ethereum/proxy/di/proxyTypes\";\nimport { safeTypes } from \"@/modules/ethereum/safe/di/safeTypes\";\nimport { tokenTypes as ethereumTokenTypes } from \"@/modules/ethereum/token/di/tokenTypes\";\nimport { trustedNameTypes } from \"@/modules/ethereum/trusted-name/di/trustedNameTypes\";\nimport { typedDataTypes } from \"@/modules/ethereum/typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"@/modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nimport { type BlindSigningReportParams } from \"@/modules/multichain/reporter/data/BlindSigningReporterDatasource\";\nimport { reporterTypes } from \"@/modules/multichain/reporter/di/reporterTypes\";\nimport { type BlindSigningReporter } from \"@/modules/multichain/reporter/domain/BlindSigningReporter\";\nimport { type SignReporter } from \"@/modules/multichain/sign-reporter/domain/SignReporter\";\nimport { type SignReportParams } from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { transactionCheckTypes } from \"@/modules/multichain/transaction-check/di/transactionCheckTypes\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { enumVariantTypes } from \"@/modules/solana/enum-variant/di/enumVariantTypes\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport { lifiTypes } from \"@/modules/solana/lifi/di/lifiTypes\";\nimport { ownerInfoTypes } from \"@/modules/solana/owner-info/di/ownerInfoTypes\";\nimport { tokenTypes as solanaTokenTypes } from \"@/modules/solana/token/di/tokenTypes\";\nimport { tokenAccountStateTypes } from \"@/modules/solana/token-account-state/di/tokenAccountStateTypes\";\nimport { tokenInfoTypes } from \"@/modules/solana/token-info/di/tokenInfoTypes\";\nimport { solanaTrustedNameTypes } from \"@/modules/solana/trusted-name/di/trustedNameTypes\";\nimport { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport { ContextModuleChainID } from \"@/shared/domain/ContextModuleChainID\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _config: ContextModuleServiceConfig & ContextModuleLoaderConfig;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n private _blindSigningReporter: BlindSigningReporter | null;\n private _signReporter: SignReporter | null;\n\n constructor(args: ContextModuleServiceConfig & ContextModuleLoaderConfig) {\n this._config = args;\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._blindSigningReporter =\n args.customBlindSigningReporter ?? this._getBlindSigningReporter();\n this._signReporter = null;\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n if (this._config.chain !== ContextModuleChainID.Ethereum) return [];\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n ethereumTokenTypes.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 const { chain } = this._config;\n switch (chain) {\n case ContextModuleChainID.Ethereum:\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>(\n ethereumTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(\n calldataTypes.CalldataContextLoader,\n ),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningContextLoader,\n ),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningTypedDataContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TypedDataCheckLoader,\n ),\n ];\n case ContextModuleChainID.Solana:\n return [\n this._container.get<ContextLoader>(\n solanaTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(lifiTypes.LifiContextLoader),\n this._container.get<ContextLoader>(\n ownerInfoTypes.OwnerInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n instructionInfoTypes.InstructionInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n enumVariantTypes.EnumVariantContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenInfoTypes.TokenInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenAccountStateTypes.TokenAccountStateContextLoader,\n ),\n this._container.get<ContextLoader>(\n altResolutionTypes.AltResolutionContextLoader,\n ),\n this._container.get<ContextLoader>(\n solanaTrustedNameTypes.SolanaTrustedNameContextLoader,\n ),\n ];\n case ContextModuleChainID.Concordium:\n return [\n this._container.get<ContextLoader>(\n accountOwnershipTypes.AccountOwnershipContextLoader,\n ),\n ];\n default: {\n const exhaustiveCheck: never = chain;\n void exhaustiveCheck;\n return [];\n }\n }\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n if (this._config.chain !== ContextModuleChainID.Ethereum) {\n return {\n load: () =>\n Promise.reject(\n new Error(\n \"[ContextModule] getTypedDataFilters is not supported for this chain\",\n ),\n ),\n };\n }\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getBlindSigningReporter(): BlindSigningReporter | null {\n if (this._container.isBound(reporterTypes.BlindSigningReporter)) {\n return this._container.get<BlindSigningReporter>(\n reporterTypes.BlindSigningReporter,\n );\n }\n return null;\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 report(params: BlindSigningReportParams): Promise<void> {\n await this._blindSigningReporter?.report(params);\n }\n\n public async signReport(params: SignReportParams): Promise<void> {\n await this._signReporter?.report(params);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAOA,OAAS,iBAAAA,MAAqB,OAC9B,OAAS,yBAAAC,MAA6B,kEACtC,OAAS,iBAAAC,MAAqB,+CAC9B,OAAS,uBAAAC,MAA2B,4DACpC,OAAS,uBAAAC,MAA2B,4DACpC,OAAS,qBAAAC,MAAyB,wDAGlC,OAAS,YAAAC,MAAgB,qCACzB,OAAS,cAAAC,MAAkB,yCAC3B,OAAS,aAAAC,MAAiB,uCAC1B,OAAS,cAAcC,MAA0B,yCACjD,OAAS,oBAAAC,MAAwB,sDACjC,OAAS,kBAAAC,MAAsB,kDAG/B,OAAS,iBAAAC,MAAqB,iDAI9B,OAAS,yBAAAC,MAA6B,kEACtC,OAAS,sBAAAC,MAA0B,wDACnC,OAAS,oBAAAC,MAAwB,oDACjC,OAAS,wBAAAC,MAA4B,4DACrC,OAAS,aAAAC,MAAiB,qCAC1B,OAAS,kBAAAC,MAAsB,gDAC/B,OAAS,cAAcC,MAAwB,uCAC/C,OAAS,0BAAAC,MAA8B,iEACvC,OAAS,kBAAAC,MAAsB,gDAC/B,OAAS,0BAAAC,MAA8B,
|
|
6
|
-
"names": ["makeContainer", "accountOwnershipTypes", "calldataTypes", "dynamicNetworkTypes", "externalPluginTypes", "gatedSigningTypes", "nftTypes", "proxyTypes", "safeTypes", "ethereumTokenTypes", "trustedNameTypes", "typedDataTypes", "reporterTypes", "transactionCheckTypes", "altResolutionTypes", "enumVariantTypes", "instructionInfoTypes", "lifiTypes", "ownerInfoTypes", "solanaTokenTypes", "tokenAccountStateTypes", "tokenInfoTypes", "solanaTrustedNameTypes", "ContextModuleChainID", "ClearSignContextType", "DefaultContextModule", "args", "chain", "exhaustiveCheck", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "params"]
|
|
4
|
+
"sourcesContent": ["import { type Container } from \"inversify\";\n\nimport {\n type ContextModuleLoaderConfig,\n type ContextModuleServiceConfig,\n} from \"@/config/model/ContextModuleConfig\";\nimport { type ContextModule } from \"@/ContextModule\";\nimport { makeContainer } from \"@/di\";\nimport { accountOwnershipTypes } from \"@/modules/concordium/account-ownership/di/accountOwnershipTypes\";\nimport { calldataTypes } from \"@/modules/ethereum/calldata/di/calldataTypes\";\nimport { dynamicNetworkTypes } from \"@/modules/ethereum/dynamic-network/di/dynamicNetworkTypes\";\nimport { externalPluginTypes } from \"@/modules/ethereum/external-plugin/di/externalPluginTypes\";\nimport { gatedSigningTypes } from \"@/modules/ethereum/gated-signing/di/gatedSigningTypes\";\nimport type { TypedDataClearSignContext } from \"@/modules/ethereum/model/TypedDataClearSignContext\";\nimport type { TypedDataContext } from \"@/modules/ethereum/model/TypedDataContext\";\nimport { nftTypes } from \"@/modules/ethereum/nft/di/nftTypes\";\nimport { proxyTypes } from \"@/modules/ethereum/proxy/di/proxyTypes\";\nimport { safeTypes } from \"@/modules/ethereum/safe/di/safeTypes\";\nimport { tokenTypes as ethereumTokenTypes } from \"@/modules/ethereum/token/di/tokenTypes\";\nimport { trustedNameTypes } from \"@/modules/ethereum/trusted-name/di/trustedNameTypes\";\nimport { typedDataTypes } from \"@/modules/ethereum/typed-data/di/typedDataTypes\";\nimport type { TypedDataContextLoader } from \"@/modules/ethereum/typed-data/domain/TypedDataContextLoader\";\nimport { type BlindSigningReportParams } from \"@/modules/multichain/reporter/data/BlindSigningReporterDatasource\";\nimport { reporterTypes } from \"@/modules/multichain/reporter/di/reporterTypes\";\nimport { type BlindSigningReporter } from \"@/modules/multichain/reporter/domain/BlindSigningReporter\";\nimport { type SignReporter } from \"@/modules/multichain/sign-reporter/domain/SignReporter\";\nimport { type SignReportParams } from \"@/modules/multichain/sign-reporter/model/SignReportParams\";\nimport { transactionCheckTypes } from \"@/modules/multichain/transaction-check/di/transactionCheckTypes\";\nimport { altResolutionTypes } from \"@/modules/solana/alt-resolution/di/altResolutionTypes\";\nimport { enumVariantTypes } from \"@/modules/solana/enum-variant/di/enumVariantTypes\";\nimport { instructionInfoTypes } from \"@/modules/solana/instruction-info/di/instructionInfoTypes\";\nimport { lifiTypes } from \"@/modules/solana/lifi/di/lifiTypes\";\nimport { ownerInfoTypes } from \"@/modules/solana/owner-info/di/ownerInfoTypes\";\nimport { tokenTypes as solanaTokenTypes } from \"@/modules/solana/token/di/tokenTypes\";\nimport { tokenAccountStateTypes } from \"@/modules/solana/token-account-state/di/tokenAccountStateTypes\";\nimport { tokenInfoTypes } from \"@/modules/solana/token-info/di/tokenInfoTypes\";\nimport { solanaTrustedNameTypes } from \"@/modules/solana/trusted-name/di/trustedNameTypes\";\nimport { tokenTypes as tronTokenTypes } from \"@/modules/tron/token/di/tokenTypes\";\nimport { type ContextFieldLoader } from \"@/shared/domain/ContextFieldLoader\";\nimport { type ContextLoader } from \"@/shared/domain/ContextLoader\";\nimport { ContextModuleChainID } from \"@/shared/domain/ContextModuleChainID\";\nimport {\n type ClearSignContext,\n ClearSignContextType,\n} from \"@/shared/model/ClearSignContext\";\n\nexport class DefaultContextModule implements ContextModule {\n private _container: Container;\n private _config: ContextModuleServiceConfig & ContextModuleLoaderConfig;\n private _loaders: ContextLoader<unknown>[];\n private _typedDataLoader: TypedDataContextLoader;\n private _fieldLoaders: ContextFieldLoader<unknown>[];\n private _blindSigningReporter: BlindSigningReporter | null;\n private _signReporter: SignReporter | null;\n\n constructor(args: ContextModuleServiceConfig & ContextModuleLoaderConfig) {\n this._config = args;\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._blindSigningReporter =\n args.customBlindSigningReporter ?? this._getBlindSigningReporter();\n this._signReporter = null;\n }\n\n private _getDefaultFieldLoaders(): ContextFieldLoader[] {\n if (this._config.chain !== ContextModuleChainID.Ethereum) return [];\n return [\n this._container.get<ContextFieldLoader>(nftTypes.NftContextFieldLoader),\n this._container.get<ContextFieldLoader>(\n ethereumTokenTypes.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 const { chain } = this._config;\n switch (chain) {\n case ContextModuleChainID.Ethereum:\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>(\n ethereumTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(\n calldataTypes.CalldataContextLoader,\n ),\n this._container.get<ContextLoader>(\n dynamicNetworkTypes.DynamicNetworkContextLoader,\n ),\n this._container.get<ContextLoader>(safeTypes.SafeAddressLoader),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningContextLoader,\n ),\n this._container.get<ContextLoader>(\n gatedSigningTypes.GatedSigningTypedDataContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TypedDataCheckLoader,\n ),\n ];\n case ContextModuleChainID.Solana:\n return [\n this._container.get<ContextLoader>(\n solanaTokenTypes.TokenContextLoader,\n ),\n this._container.get<ContextLoader>(lifiTypes.LifiContextLoader),\n this._container.get<ContextLoader>(\n ownerInfoTypes.OwnerInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n transactionCheckTypes.TransactionCheckLoader,\n ),\n this._container.get<ContextLoader>(\n instructionInfoTypes.InstructionInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n enumVariantTypes.EnumVariantContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenInfoTypes.TokenInfoContextLoader,\n ),\n this._container.get<ContextLoader>(\n tokenAccountStateTypes.TokenAccountStateContextLoader,\n ),\n this._container.get<ContextLoader>(\n altResolutionTypes.AltResolutionContextLoader,\n ),\n this._container.get<ContextLoader>(\n solanaTrustedNameTypes.SolanaTrustedNameContextLoader,\n ),\n ];\n case ContextModuleChainID.Concordium:\n return [\n this._container.get<ContextLoader>(\n accountOwnershipTypes.AccountOwnershipContextLoader,\n ),\n ];\n case ContextModuleChainID.Tron:\n return [\n this._container.get<ContextLoader>(tronTokenTypes.TokenContextLoader),\n ];\n default: {\n const exhaustiveCheck: never = chain;\n void exhaustiveCheck;\n return [];\n }\n }\n }\n\n private _getDefaultTypedDataLoader(): TypedDataContextLoader {\n if (this._config.chain !== ContextModuleChainID.Ethereum) {\n return {\n load: () =>\n Promise.reject(\n new Error(\n \"[ContextModule] getTypedDataFilters is not supported for this chain\",\n ),\n ),\n };\n }\n return this._container.get<TypedDataContextLoader>(\n typedDataTypes.TypedDataContextLoader,\n );\n }\n\n private _getBlindSigningReporter(): BlindSigningReporter | null {\n if (this._container.isBound(reporterTypes.BlindSigningReporter)) {\n return this._container.get<BlindSigningReporter>(\n reporterTypes.BlindSigningReporter,\n );\n }\n return null;\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 report(params: BlindSigningReportParams): Promise<void> {\n await this._blindSigningReporter?.report(params);\n }\n\n public async signReport(params: SignReportParams): Promise<void> {\n await this._signReporter?.report(params);\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["makeContainer", "accountOwnershipTypes", "calldataTypes", "dynamicNetworkTypes", "externalPluginTypes", "gatedSigningTypes", "nftTypes", "proxyTypes", "safeTypes", "ethereumTokenTypes", "trustedNameTypes", "typedDataTypes", "reporterTypes", "transactionCheckTypes", "altResolutionTypes", "enumVariantTypes", "instructionInfoTypes", "lifiTypes", "ownerInfoTypes", "solanaTokenTypes", "tokenAccountStateTypes", "tokenInfoTypes", "solanaTrustedNameTypes", "tronTokenTypes", "ContextModuleChainID", "ClearSignContextType", "DefaultContextModule", "args", "chain", "exhaustiveCheck", "input", "expectedTypes", "allContextTypes", "promises", "l", "fetcher", "field", "expectedType", "loaders", "loader", "context", "typedData", "params"]
|
|
7
7
|
}
|
package/lib/esm/src/di.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Container as i}from"inversify";import{configModuleFactory as c}from"./config/di/configModuleFactory";import{configTypes as u}from"./config/di/configTypes";import{accountOwnershipModuleFactory as l}from"./modules/concordium/account-ownership/di/accountOwnershipModuleFactory";import{calldataModuleFactory as d}from"./modules/ethereum/calldata/di/calldataModuleFactory";import{dynamicNetworkModuleFactory as
|
|
1
|
+
import{Container as i}from"inversify";import{configModuleFactory as c}from"./config/di/configModuleFactory";import{configTypes as u}from"./config/di/configTypes";import{accountOwnershipModuleFactory as l}from"./modules/concordium/account-ownership/di/accountOwnershipModuleFactory";import{calldataModuleFactory as d}from"./modules/ethereum/calldata/di/calldataModuleFactory";import{dynamicNetworkModuleFactory as y}from"./modules/ethereum/dynamic-network/di/dynamicNetworkModuleFactory";import{externalPluginModuleFactory as p}from"./modules/ethereum/external-plugin/di/externalPluginModuleFactory";import{gatedSigningModuleFactory as f}from"./modules/ethereum/gated-signing/di/gatedSigningModuleFactory";import{nftModuleFactory as M}from"./modules/ethereum/nft/di/nftModuleFactory";import{proxyModuleFactory as s}from"./modules/ethereum/proxy/di/proxyModuleFactory";import{safeModuleFactory as F}from"./modules/ethereum/safe/di/safeModuleFactory";import{tokenModuleFactory as k}from"./modules/ethereum/token/di/tokenModuleFactory";import{trustedNameModuleFactory as C}from"./modules/ethereum/trusted-name/di/trustedNameModuleFactory";import{typedDataModuleFactory as g}from"./modules/ethereum/typed-data/di/typedDataModuleFactory";import{uniswapModuleFactory as h}from"./modules/ethereum/uniswap/di/uniswapModuleFactory";import{nanoPkiModuleFactory as e}from"./modules/multichain/pki/di/pkiModuleFactory";import{reporterModuleFactory as S}from"./modules/multichain/reporter/di/reporterModuleFactory";import{signReporterModuleFactory as m}from"./modules/multichain/sign-reporter/di/signReporterModuleFactory";import{ethereumTransactionCheckModuleFactory as x}from"./modules/multichain/transaction-check/di/ethereumTransactionCheckModuleFactory";import{solanaTransactionCheckModuleFactory as T}from"./modules/multichain/transaction-check/di/solanaTransactionCheckModuleFactory";import{altResolutionModuleFactory as b}from"./modules/solana/alt-resolution/di/altResolutionModuleFactory";import{enumVariantModuleFactory as v}from"./modules/solana/enum-variant/di/enumVariantModuleFactory";import{instructionInfoModuleFactory as w}from"./modules/solana/instruction-info/di/instructionInfoModuleFactory";import{lifiModuleFactory as L}from"./modules/solana/lifi/di/lifiModuleFactory";import{ownerInfoModuleFactory as I}from"./modules/solana/owner-info/di/ownerInfoModuleFactory";import{tokenModuleFactory as N}from"./modules/solana/token/di/tokenModuleFactory";import{tokenAccountStateModuleFactory as P}from"./modules/solana/token-account-state/di/tokenAccountStateModuleFactory";import{tokenInfoModuleFactory as A}from"./modules/solana/token-info/di/tokenInfoModuleFactory";import{solanaTrustedNameModuleFactory as D}from"./modules/solana/trusted-name/di/trustedNameModuleFactory";import{tokenModuleFactory as R}from"./modules/tron/token/di/tokenModuleFactory";import{ContextModuleChainID as t}from"./shared/domain/ContextModuleChainID";import{networkModuleFactory as V}from"./shared/network/di/networkModuleFactory";const Mo=({config:r})=>{const o=new i;o.bind(u.ContextModuleLoggerFactory).toConstantValue(r.loggerFactory);const{chain:a}=r;switch(o.loadSync(c(r),V(r)),a){case t.Ethereum:o.loadSync(e(),S(),m(),C(r.customTrustedNameDataSource),p(),y(),M(),s(r.datasource),F(),f(),k(),d(),g(),h(),x());break;case t.Solana:o.loadSync(e(),m(),I(),N(),L(),T(),w(),v(),A(),P(),b(),D());break;case t.Concordium:o.loadSync(e(),l());break;case t.Tron:o.loadSync(R());break;default:{const n=a}}return o};export{Mo as makeContainer};
|
|
2
2
|
//# sourceMappingURL=di.js.map
|