@trustline.id/web3sdk 1.0.0 → 1.0.2
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/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +1 -1
- package/artifacts/build-info/4e12cf8d4e7d83312021b55f7d8cf16d.json +1 -0
- package/artifacts/contracts/Trustlined.sol/Trustlined.dbg.json +1 -1
- package/artifacts/contracts/examples/PaymentFirewall.sol/PaymentFirewall.dbg.json +1 -1
- package/artifacts/contracts/examples/PaymentFirewall.sol/PaymentFirewall.json +2 -2
- package/artifacts/contracts/interfaces/IValidationEngine.sol/IValidationEngine.dbg.json +1 -1
- package/artifacts/contracts/interfaces/IValidationEngine.sol/IValidationEngine.json +72 -0
- package/contracts/Trustlined.sol +6 -6
- package/contracts/examples/PaymentFirewall.sol +2 -5
- package/contracts/interfaces/IValidationEngine.sol +42 -5
- package/package.json +2 -2
- package/artifacts/build-info/59243712b3c2b7c16f9bd43f3a3a6442.json +0 -1
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"type": "function"
|
|
65
65
|
}
|
|
66
66
|
],
|
|
67
|
-
"bytecode": "
|
|
68
|
-
"deployedBytecode": "
|
|
67
|
+
"bytecode": "0x608060405234801561000f575f5ffd5b5060405161077f38038061077f83398101604081905261002e916100c8565b806100388161003f565b50506100f5565b6100488161004b565b50565b5f546001600160a01b0316156100a75760405162461bcd60e51b815260206004820152601360248201527f416c726561647920696e697469616c697a656400000000000000000000000000604482015260640160405180910390fd5b5f80546001600160a01b0319166001600160a01b0392909216919091179055565b5f602082840312156100d8575f5ffd5b81516001600160a01b03811681146100ee575f5ffd5b9392505050565b61067d806101025f395ff3fe608060405260043610610033575f3560e01c80632be277aa14610037578063666c6f23146100585780637d4f064e1461006b575b5f5ffd5b348015610042575f5ffd5b506100566100513660046104d0565b6100bf565b005b61005661006636600461050e565b610297565b348015610076575f5ffd5b505f546100969073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6040805160028082526060820183525f9260208301908036833701905050905033815f815181106100f2576100f2610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050838160018151811061014057610140610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061018381610426565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8581166024830152604482018490525f91908516906323b872dd906064016020604051808303815f875af11580156101fe573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610222919061055d565b905080610290576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e61626c6520746f2070617920746f6b656e7300000000000000000000000060448201526064015b60405180910390fd5b5050505050565b6040805160028082526060820183525f9260208301908036833701905050905033815f815181106102ca576102ca610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050818160018151811061031857610318610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061035b81610426565b5f8273ffffffffffffffffffffffffffffffffffffffff16346040515f6040518083038185875af1925050503d805f81146103b1576040519150601f19603f3d011682016040523d82523d5f602084013e6103b6565b606091505b5050905080610421576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e61626c6520746f20706179206574686572730000000000000000000000006044820152606401610287565b505050565b5f80546040517f6cfd0c0900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691636cfd0c09916104839133913491903690889060040161057c565b5f604051808303815f87803b15801561049a575f5ffd5b505af1158015610290573d5f5f3e3d5ffd5b73ffffffffffffffffffffffffffffffffffffffff811681146104cd575f5ffd5b50565b5f5f5f606084860312156104e2575f5ffd5b83356104ed816104ac565b925060208401356104fd816104ac565b929592945050506040919091013590565b5f6020828403121561051e575f5ffd5b8135610529816104ac565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6020828403121561056d575f5ffd5b81518015158114610529575f5ffd5b73ffffffffffffffffffffffffffffffffffffffff8616815284602082015260806040820152826080820152828460a08301375f60a084830181018290527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f86011683018381038201606085015284519181018290526020850191839160c001905b808310156106395773ffffffffffffffffffffffffffffffffffffffff8451168252602082019150602084019350600183019250610600565b50999850505050505050505056fea2646970667358221220782b6fae4b1923bb60065e28cd482c78fbc66b53903b8b529a41d440886f143e64736f6c634300081c0033",
|
|
68
|
+
"deployedBytecode": "0x608060405260043610610033575f3560e01c80632be277aa14610037578063666c6f23146100585780637d4f064e1461006b575b5f5ffd5b348015610042575f5ffd5b506100566100513660046104d0565b6100bf565b005b61005661006636600461050e565b610297565b348015610076575f5ffd5b505f546100969073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6040805160028082526060820183525f9260208301908036833701905050905033815f815181106100f2576100f2610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050838160018151811061014057610140610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061018381610426565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8581166024830152604482018490525f91908516906323b872dd906064016020604051808303815f875af11580156101fe573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610222919061055d565b905080610290576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e61626c6520746f2070617920746f6b656e7300000000000000000000000060448201526064015b60405180910390fd5b5050505050565b6040805160028082526060820183525f9260208301908036833701905050905033815f815181106102ca576102ca610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050818160018151811061031857610318610530565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061035b81610426565b5f8273ffffffffffffffffffffffffffffffffffffffff16346040515f6040518083038185875af1925050503d805f81146103b1576040519150601f19603f3d011682016040523d82523d5f602084013e6103b6565b606091505b5050905080610421576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e61626c6520746f20706179206574686572730000000000000000000000006044820152606401610287565b505050565b5f80546040517f6cfd0c0900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691636cfd0c09916104839133913491903690889060040161057c565b5f604051808303815f87803b15801561049a575f5ffd5b505af1158015610290573d5f5f3e3d5ffd5b73ffffffffffffffffffffffffffffffffffffffff811681146104cd575f5ffd5b50565b5f5f5f606084860312156104e2575f5ffd5b83356104ed816104ac565b925060208401356104fd816104ac565b929592945050506040919091013590565b5f6020828403121561051e575f5ffd5b8135610529816104ac565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6020828403121561056d575f5ffd5b81518015158114610529575f5ffd5b73ffffffffffffffffffffffffffffffffffffffff8616815284602082015260806040820152826080820152828460a08301375f60a084830181018290527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f86011683018381038201606085015284519181018290526020850191839160c001905b808310156106395773ffffffffffffffffffffffffffffffffffffffff8451168252602082019150602084019350600183019250610600565b50999850505050505050505056fea2646970667358221220782b6fae4b1923bb60065e28cd482c78fbc66b53903b8b529a41d440886f143e64736f6c634300081c0033",
|
|
69
69
|
"linkReferences": {},
|
|
70
70
|
"deployedLinkReferences": {}
|
|
71
71
|
}
|
|
@@ -32,6 +32,45 @@
|
|
|
32
32
|
"stateMutability": "view",
|
|
33
33
|
"type": "function"
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
"inputs": [
|
|
37
|
+
{
|
|
38
|
+
"internalType": "enum IValidationEngine.ValidationMode",
|
|
39
|
+
"name": "mode",
|
|
40
|
+
"type": "uint8"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"internalType": "address",
|
|
44
|
+
"name": "sender",
|
|
45
|
+
"type": "address"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"internalType": "uint256",
|
|
49
|
+
"name": "value",
|
|
50
|
+
"type": "uint256"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"internalType": "bytes",
|
|
54
|
+
"name": "data",
|
|
55
|
+
"type": "bytes"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"internalType": "address[]",
|
|
59
|
+
"name": "addresses",
|
|
60
|
+
"type": "address[]"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"name": "checkTrustlineStatus",
|
|
64
|
+
"outputs": [
|
|
65
|
+
{
|
|
66
|
+
"internalType": "bool",
|
|
67
|
+
"name": "",
|
|
68
|
+
"type": "bool"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"stateMutability": "view",
|
|
72
|
+
"type": "function"
|
|
73
|
+
},
|
|
35
74
|
{
|
|
36
75
|
"inputs": [
|
|
37
76
|
{
|
|
@@ -116,6 +155,39 @@
|
|
|
116
155
|
"outputs": [],
|
|
117
156
|
"stateMutability": "nonpayable",
|
|
118
157
|
"type": "function"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"inputs": [
|
|
161
|
+
{
|
|
162
|
+
"internalType": "enum IValidationEngine.ValidationMode",
|
|
163
|
+
"name": "mode",
|
|
164
|
+
"type": "uint8"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"internalType": "address",
|
|
168
|
+
"name": "sender",
|
|
169
|
+
"type": "address"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"internalType": "uint256",
|
|
173
|
+
"name": "value",
|
|
174
|
+
"type": "uint256"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"internalType": "bytes",
|
|
178
|
+
"name": "data",
|
|
179
|
+
"type": "bytes"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"internalType": "address[]",
|
|
183
|
+
"name": "addresses",
|
|
184
|
+
"type": "address[]"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"name": "requireTrustline",
|
|
188
|
+
"outputs": [],
|
|
189
|
+
"stateMutability": "nonpayable",
|
|
190
|
+
"type": "function"
|
|
119
191
|
}
|
|
120
192
|
],
|
|
121
193
|
"bytecode": "0x",
|
package/contracts/Trustlined.sol
CHANGED
|
@@ -9,7 +9,7 @@ import {IValidationEngine} from "./interfaces/IValidationEngine.sol";
|
|
|
9
9
|
abstract contract Trustlined {
|
|
10
10
|
/// @notice The Trustline ValidationEngine contract address. It must be set before any of the provided functions can be used
|
|
11
11
|
/// @dev Multiple dapps can share the same ValidationEngine contract
|
|
12
|
-
/// @dev This contract is set by the owner and must implement the
|
|
12
|
+
/// @dev This contract is set by the owner and must implement the IValidationEngine interface
|
|
13
13
|
IValidationEngine public validationEngine;
|
|
14
14
|
|
|
15
15
|
/// @dev Both a constructor and initializer functions are defined to support both upgradeable and non-upgradeable deployment scenarios
|
|
@@ -26,24 +26,24 @@ abstract contract Trustlined {
|
|
|
26
26
|
validationEngine = IValidationEngine(validationEngine_);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/// @notice Checks
|
|
29
|
+
/// @notice Checks whether a transaction is trusted and verifies msg.sender + addresses[] against sanctions lists
|
|
30
30
|
/// @param addresses An array of addresses that will be verified by the policy
|
|
31
31
|
function checkTrustlineStatus(address[] memory addresses) internal view returns (bool) {
|
|
32
32
|
return validationEngine.checkTrustlineStatus(msg.sender, msg.value, msg.data, addresses);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/// @notice Checks
|
|
36
|
-
function
|
|
35
|
+
/// @notice Checks whether a transaction is trusted and verifies msg.sender against sanctions lists
|
|
36
|
+
function checkTrustlineStatus() internal view returns (bool) {
|
|
37
37
|
return validationEngine.checkTrustlineStatus(msg.sender, msg.value, msg.data);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/// @notice Requires a trusted transaction
|
|
40
|
+
/// @notice Requires a trusted transaction and non‑sanctioned msg.sender + addresses[]
|
|
41
41
|
/// @param addresses An array of addresses that will be verified by the policy
|
|
42
42
|
function requireTrustline(address[] memory addresses) internal {
|
|
43
43
|
validationEngine.requireTrustline(msg.sender, msg.value, msg.data, addresses);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/// @notice Requires a trusted transaction
|
|
46
|
+
/// @notice Requires a trusted transaction and a non‑sanctioned msg.sender
|
|
47
47
|
function requireTrustline() internal {
|
|
48
48
|
validationEngine.requireTrustline(msg.sender, msg.value, msg.data);
|
|
49
49
|
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
-
import {Trustlined
|
|
5
|
+
//import {Trustlined} from "@trustline.id/web3sdk/contracts/Trustlined.sol";
|
|
6
|
+
import {Trustlined} from "../Trustlined.sol";
|
|
6
7
|
|
|
7
8
|
/// @title PaymentFirewall
|
|
8
9
|
/// @author Trustline
|
|
@@ -34,7 +35,3 @@ contract PaymentFirewall is Trustlined {
|
|
|
34
35
|
require(sent, "Unable to pay tokens");
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
|
|
40
|
-
*/
|
|
@@ -6,7 +6,28 @@ pragma solidity ^0.8;
|
|
|
6
6
|
/// @notice This interface defines the functions that must be implemented by the validation contract
|
|
7
7
|
/// @dev This interface is used by the Trustlined contract to interact with Trustline's Validation contract
|
|
8
8
|
interface IValidationEngine {
|
|
9
|
-
|
|
9
|
+
enum ValidationMode {
|
|
10
|
+
Dapp,
|
|
11
|
+
UniswapV4
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// @notice Checks whether a transaction is trusted and verifies msg.sender + addresses[] against sanctions lists (advanced)
|
|
15
|
+
/// @dev This call is required only in complex scenarios
|
|
16
|
+
/// @dev WARNING: Improper use of this call may introduce security vulnerabilities in the calling contract
|
|
17
|
+
/// @param mode The validation mode
|
|
18
|
+
/// @param sender The transaction sender
|
|
19
|
+
/// @param value Transaction value in wei
|
|
20
|
+
/// @param data Transaction payload data
|
|
21
|
+
/// @param addresses An array of addresses that will be verified by the policy
|
|
22
|
+
function checkTrustlineStatus(
|
|
23
|
+
ValidationMode mode,
|
|
24
|
+
address sender,
|
|
25
|
+
uint256 value,
|
|
26
|
+
bytes calldata data,
|
|
27
|
+
address[] memory addresses
|
|
28
|
+
) external view returns (bool);
|
|
29
|
+
|
|
30
|
+
/// @notice Checks whether a transaction is trusted and verifies msg.sender + addresses[] against sanctions lists
|
|
10
31
|
/// @param sender The transaction sender
|
|
11
32
|
/// @param value Transaction value in wei
|
|
12
33
|
/// @param data Transaction payload data
|
|
@@ -18,7 +39,7 @@ interface IValidationEngine {
|
|
|
18
39
|
address[] memory addresses
|
|
19
40
|
) external view returns (bool);
|
|
20
41
|
|
|
21
|
-
/// @notice Checks
|
|
42
|
+
/// @notice Checks whether a transaction is trusted and verifies msg.sender against sanctions lists
|
|
22
43
|
/// @param sender The transaction sender
|
|
23
44
|
/// @param value Transaction value in wei
|
|
24
45
|
/// @param data Transaction payload data
|
|
@@ -28,7 +49,23 @@ interface IValidationEngine {
|
|
|
28
49
|
bytes calldata data
|
|
29
50
|
) external view returns (bool);
|
|
30
51
|
|
|
31
|
-
/// @notice Requires a trusted transaction
|
|
52
|
+
/// @notice Requires a trusted transaction and non‑sanctioned msg.sender + addresses[] (advanced)
|
|
53
|
+
/// @dev This call is required only in complex scenarios
|
|
54
|
+
/// @dev WARNING: Improper use of this call may introduce security vulnerabilities in the calling contract
|
|
55
|
+
/// @param mode The validation mode
|
|
56
|
+
/// @param sender The transaction sender
|
|
57
|
+
/// @param value Transaction value in wei
|
|
58
|
+
/// @param data Transaction payload data
|
|
59
|
+
/// @param addresses An array of addresses that will be verified by the policy
|
|
60
|
+
function requireTrustline(
|
|
61
|
+
ValidationMode mode,
|
|
62
|
+
address sender,
|
|
63
|
+
uint256 value,
|
|
64
|
+
bytes calldata data,
|
|
65
|
+
address[] memory addresses
|
|
66
|
+
) external;
|
|
67
|
+
|
|
68
|
+
/// @notice Requires a trusted transaction and non‑sanctioned msg.sender + addresses[]
|
|
32
69
|
/// @dev reverts if the transaction is not compliant
|
|
33
70
|
/// @param sender The transaction sender
|
|
34
71
|
/// @param value Transaction value in wei
|
|
@@ -41,7 +78,7 @@ interface IValidationEngine {
|
|
|
41
78
|
address[] memory addresses
|
|
42
79
|
) external;
|
|
43
80
|
|
|
44
|
-
/// @notice Requires a trusted transaction
|
|
81
|
+
/// @notice Requires a trusted transaction and a non‑sanctioned msg.sender
|
|
45
82
|
/// @dev reverts if the transaction is not compliant
|
|
46
83
|
/// @param sender The transaction sender
|
|
47
84
|
/// @param value Transaction value in wei
|
|
@@ -51,4 +88,4 @@ interface IValidationEngine {
|
|
|
51
88
|
uint256 value,
|
|
52
89
|
bytes calldata data
|
|
53
90
|
) external;
|
|
54
|
-
}
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustline.id/web3sdk",
|
|
3
3
|
"description": "Protects EVM-compatible smart contracts from unauthorized access and malicious transactions",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"compile": "hardhat compile",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://www.trustline.id",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@openzeppelin/contracts": "^5.
|
|
37
|
+
"@openzeppelin/contracts": "^5.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"browserify": "^17.0.1",
|