-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (context-module): Implement generic transaction context loader
- Loading branch information
1 parent
9037e4b
commit 282f536
Showing
15 changed files
with
1,395 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ledgerhq/context-module": minor | ||
--- | ||
|
||
Implement generic transaction context loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
packages/signer/context-module/src/transaction/data/CalldataDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
export interface CalldataDto { | ||
descriptors_calldata: { | ||
[address: string]: { | ||
[selector: string]: CalldataDescriptor; | ||
}; | ||
}; | ||
} | ||
|
||
export type CalldataDescriptor = CalldataDescriptorV1; // For now only V1 descriptors are supported | ||
|
||
export interface CalldataDescriptorV1 { | ||
type: "calldata"; | ||
version: "v1"; | ||
transaction_info: CalldataTransactionInfoV1; | ||
enums: CalldataEnumV1[]; | ||
fields: CalldataFieldV1[]; | ||
} | ||
|
||
export type CalldataTransactionDescriptor = { | ||
data: string; | ||
signatures: CalldataSignatures; | ||
}; | ||
|
||
export type CalldataSignatures = | ||
| { | ||
prod: string; | ||
test?: string; | ||
} | ||
| { | ||
prod?: string; | ||
test: string; | ||
}; | ||
|
||
export interface CalldataTransactionInfoV1 { | ||
descriptor: CalldataTransactionDescriptor; | ||
} | ||
|
||
export interface CalldataEnumV1 { | ||
descriptor: string; | ||
} | ||
|
||
export interface CalldataFieldV1 { | ||
descriptor: string; | ||
param: CalldataDescriptorParam; | ||
} | ||
|
||
export type CalldataDescriptorParam = | ||
| CalldataDescriptorParamRawV1 | ||
| CalldataDescriptorParamAmountV1 | ||
| CalldataDescriptorParamTokenAmountV1 | ||
| CalldataDescriptorParamNFTV1 | ||
| CalldataDescriptorParamDatetimeV1 | ||
| CalldataDescriptorParamDurationV1 | ||
| CalldataDescriptorParamUnitV1 | ||
| CalldataDescriptorParamEnumV1 | ||
| CalldataDescriptorParamTrustedNameV1; | ||
|
||
export interface CalldataDescriptorParamRawV1 { | ||
type: "RAW"; | ||
value: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamAmountV1 { | ||
type: "AMOUNT"; | ||
value: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamTokenAmountV1 { | ||
type: "TOKEN_AMOUNT"; | ||
value: CalldataDescriptorValueV1; | ||
token?: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamNFTV1 { | ||
type: "NFT"; | ||
value: CalldataDescriptorValueV1; | ||
collection: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamDatetimeV1 { | ||
type: "DATETIME"; | ||
value: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamDurationV1 { | ||
type: "DURATION"; | ||
value: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamUnitV1 { | ||
type: "UNIT"; | ||
value: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamEnumV1 { | ||
type: "ENUM"; | ||
value: CalldataDescriptorValueV1; | ||
} | ||
|
||
export interface CalldataDescriptorParamTrustedNameV1 { | ||
type: "TRUSTED_NAME"; | ||
value: CalldataDescriptorValueV1; | ||
types: string[]; | ||
sources: string[]; | ||
} | ||
|
||
export interface CalldataDescriptorValueV1 { | ||
binary_path: | ||
| CalldataDescriptorContainerPathV1 | ||
| CalldataDescriptorPathElementsV1; | ||
type_family: CalldataDescriptorTypeFamilyV1; | ||
type_size?: number; | ||
} | ||
|
||
export interface CalldataDescriptorPathElementsV1 { | ||
elements: CalldataDescriptorPathElementV1[]; | ||
} | ||
|
||
export type CalldataDescriptorPathElementV1 = | ||
| CalldataDescriptorPathElementTupleV1 | ||
| CalldataDescriptorPathElementArrayV1 | ||
| CalldataDescriptorPathElementRefV1 | ||
| CalldataDescriptorPathElementLeafV1 | ||
| CalldataDescriptorPathElementSliceV1; | ||
|
||
export interface CalldataDescriptorPathElementTupleV1 { | ||
type: "TUPLE"; | ||
offset: number; | ||
} | ||
|
||
export interface CalldataDescriptorPathElementArrayV1 { | ||
type: "ARRAY"; | ||
start?: number; | ||
length?: number; | ||
weight: number; | ||
} | ||
|
||
export interface CalldataDescriptorPathElementRefV1 { | ||
type: "REF"; | ||
} | ||
|
||
export interface CalldataDescriptorPathElementLeafV1 { | ||
type: "LEAF"; | ||
leaf_type: CalldataDescriptorPathLeafTypeV1; | ||
} | ||
|
||
export interface CalldataDescriptorPathElementSliceV1 { | ||
type: "SLICE"; | ||
start?: number; | ||
end?: number; | ||
} | ||
|
||
export type CalldataDescriptorContainerPathV1 = "FROM" | "TO" | "VALUE"; | ||
export type CalldataDescriptorPathLeafTypeV1 = | ||
| "ARRAY_LEAF" | ||
| "TUPLE_LEAF" | ||
| "STATIC_LEAF" | ||
| "DYNAMIC_LEAF"; | ||
export type CalldataDescriptorTypeFamilyV1 = | ||
| "UINT" | ||
| "INT" | ||
| "UFIXED" | ||
| "FIXED" | ||
| "ADDRESS" | ||
| "BOOL" | ||
| "BYTES" | ||
| "STRING"; |
Oops, something went wrong.