-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(context-module): add external plugin loader
- Loading branch information
1 parent
b76691c
commit 47ec609
Showing
14 changed files
with
1,057 additions
and
24 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
libs/ledgerjs/packages/context-module/src/external-plugin/__tests__/abi.json
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,92 @@ | ||
[ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address[]", | ||
"name": "fromToken", | ||
"type": "address[]" | ||
} | ||
], | ||
"name": "arrayParam", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address", | ||
"name": "address1", | ||
"type": "address" | ||
}, | ||
{ | ||
"components": [ | ||
{ | ||
"components": [ | ||
{ | ||
"components": [ | ||
{ | ||
"internalType": "address[]", | ||
"name": "addresses", | ||
"type": "address[]" | ||
} | ||
], | ||
"internalType": "struct SimpleContract.Struct3", | ||
"name": "param3", | ||
"type": "tuple" | ||
} | ||
], | ||
"internalType": "struct SimpleContract.Struct2[]", | ||
"name": "param2", | ||
"type": "tuple[]" | ||
} | ||
], | ||
"internalType": "struct SimpleContract.Struct1", | ||
"name": "param1", | ||
"type": "tuple" | ||
} | ||
], | ||
"internalType": "struct SimpleContract.ComplexStruct", | ||
"name": "complexStruct", | ||
"type": "tuple" | ||
} | ||
], | ||
"name": "complexStructParam", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "fromToken", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "toToken", | ||
"type": "address" | ||
} | ||
], | ||
"name": "multipleParams", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "fromToken", | ||
"type": "address" | ||
} | ||
], | ||
"name": "singleParam", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
38 changes: 38 additions & 0 deletions
38
libs/ledgerjs/packages/context-module/src/external-plugin/__tests__/contract.sol
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,38 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity >=0.8.2 <0.9.0; | ||
|
||
contract SimpleContract { | ||
struct Struct3 { | ||
address[] addresses; | ||
} | ||
|
||
struct Struct2 { | ||
Struct3 param3; | ||
} | ||
|
||
struct Struct1 { | ||
Struct2[] param2; | ||
} | ||
|
||
struct ComplexStruct { | ||
address address1; | ||
Struct1 param1; | ||
} | ||
|
||
function singleParam(address fromToken) public { | ||
// Do nothing | ||
} | ||
|
||
function multipleParams(address fromToken, address toToken) public { | ||
// Do nothing | ||
} | ||
|
||
function arrayParam(address[] calldata fromToken) public { | ||
// Do nothing | ||
} | ||
|
||
function complexStructParam(ComplexStruct calldata complexStruct) public { | ||
// Do nothing | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
libs/ledgerjs/packages/context-module/src/external-plugin/data/DappDTO.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,40 @@ | ||
export interface DappDTO { | ||
b2c: B2c; | ||
abis: Abis; | ||
b2c_signatures: B2cSignatures; | ||
} | ||
|
||
export interface B2c { | ||
blockchainName: string; | ||
chainId: number; | ||
contracts: Contract[]; | ||
name: string; | ||
} | ||
|
||
interface Contract { | ||
address: string; | ||
contractName: string; | ||
selectors: { [selector: string]: ContractSelector }; | ||
} | ||
|
||
interface ContractSelector { | ||
erc20OfInterest: string[]; | ||
method: string; | ||
plugin: string; | ||
} | ||
|
||
export interface Abis { | ||
[address: string]: object; | ||
} | ||
|
||
export interface B2cSignatures { | ||
[address: string]: { | ||
[selector: string]: B2cSignature; | ||
}; | ||
} | ||
|
||
interface B2cSignature { | ||
plugin: string; | ||
serialized_data: string; | ||
signature: string; | ||
} |
11 changes: 11 additions & 0 deletions
11
libs/ledgerjs/packages/context-module/src/external-plugin/data/ExternalPluginDataSource.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,11 @@ | ||
import { DappInfos } from "../model/DappInfos"; | ||
|
||
export type GetDappInfos = { | ||
address: string; | ||
selector: `0x${string}`; | ||
chainId: number; | ||
}; | ||
|
||
export interface ExternalPluginDataSource { | ||
getDappInfos(params: GetDappInfos): Promise<DappInfos | undefined>; | ||
} |
Oops, something went wrong.