@layerzerolabs/protocol-v2-oapp-evm-contracts 1.2.95
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/README.md +15 -0
- package/contracts/oapp/OApp.sol +39 -0
- package/contracts/oapp/OAppCore.sol +83 -0
- package/contracts/oapp/OAppRead.sol +18 -0
- package/contracts/oapp/OAppReceiver.sol +122 -0
- package/contracts/oapp/OAppSender.sol +124 -0
- package/contracts/oapp/examples/CmdCodecV1Mock.sol +31 -0
- package/contracts/oapp/examples/LzReadCounter.sol +160 -0
- package/contracts/oapp/examples/OmniCounter.sol +15 -0
- package/contracts/oapp/examples/OmniCounterAbstract.sol +285 -0
- package/contracts/oapp/examples/OmniCounterAlt.sol +90 -0
- package/contracts/oapp/examples/OmniCounterPreCrime.sol +102 -0
- package/contracts/oapp/interfaces/IOAppComposer.sol +12 -0
- package/contracts/oapp/interfaces/IOAppComputer.sol +8 -0
- package/contracts/oapp/interfaces/IOAppComputerMap.sol +7 -0
- package/contracts/oapp/interfaces/IOAppComputerReduce.sol +7 -0
- package/contracts/oapp/interfaces/IOAppCore.sol +52 -0
- package/contracts/oapp/interfaces/IOAppMsgInspector.sol +22 -0
- package/contracts/oapp/interfaces/IOAppOptionsType3.sol +43 -0
- package/contracts/oapp/interfaces/IOAppReceiver.sol +25 -0
- package/contracts/oapp/libs/OAppOptionsType3.sol +98 -0
- package/contracts/oapp/libs/OptionsBuilder.sol +218 -0
- package/contracts/oapp/libs/ReadCmdCodecV1.sol +231 -0
- package/contracts/oapp/utils/RateLimiter.sol +229 -0
- package/contracts/oft/OFT.sol +89 -0
- package/contracts/oft/OFTAdapter.sol +106 -0
- package/contracts/oft/OFTCore.sol +399 -0
- package/contracts/oft/OFTPrecrime.sol +99 -0
- package/contracts/oft/interfaces/IOFT.sol +149 -0
- package/contracts/oft/libs/OFTComposeMsgCodec.sol +91 -0
- package/contracts/oft/libs/OFTMsgCodec.sol +83 -0
- package/contracts/precrime/OAppPreCrimeSimulator.sol +125 -0
- package/contracts/precrime/PreCrime.sol +211 -0
- package/contracts/precrime/extensions/PreCrimeE1.sol +30 -0
- package/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol +55 -0
- package/contracts/precrime/interfaces/IPreCrime.sol +40 -0
- package/contracts/precrime/libs/Packet.sol +61 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.20;
|
|
4
|
+
|
|
5
|
+
import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
|
|
6
|
+
import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title InboundPacket
|
|
10
|
+
* @dev Structure representing an inbound packet received by the contract.
|
|
11
|
+
*/
|
|
12
|
+
struct InboundPacket {
|
|
13
|
+
Origin origin; // Origin information of the packet.
|
|
14
|
+
uint32 dstEid; // Destination endpointId of the packet.
|
|
15
|
+
address receiver; // Receiver address for the packet.
|
|
16
|
+
bytes32 guid; // Unique identifier of the packet.
|
|
17
|
+
uint256 value; // msg.value of the packet.
|
|
18
|
+
address executor; // Executor address for the packet.
|
|
19
|
+
bytes message; // Message payload of the packet.
|
|
20
|
+
bytes extraData; // Additional arbitrary data for the packet.
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @title PacketDecoder
|
|
25
|
+
* @dev Library for decoding LayerZero packets.
|
|
26
|
+
*/
|
|
27
|
+
library PacketDecoder {
|
|
28
|
+
using PacketV1Codec for bytes;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @dev Decode an inbound packet from the given packet data.
|
|
32
|
+
* @param _packet The packet data to decode.
|
|
33
|
+
* @return packet An InboundPacket struct representing the decoded packet.
|
|
34
|
+
*/
|
|
35
|
+
function decode(bytes calldata _packet) internal pure returns (InboundPacket memory packet) {
|
|
36
|
+
packet.origin = Origin(_packet.srcEid(), _packet.sender(), _packet.nonce());
|
|
37
|
+
packet.dstEid = _packet.dstEid();
|
|
38
|
+
packet.receiver = _packet.receiverB20();
|
|
39
|
+
packet.guid = _packet.guid();
|
|
40
|
+
packet.message = _packet.message();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @dev Decode multiple inbound packets from the given packet data and associated message values.
|
|
45
|
+
* @param _packets An array of packet data to decode.
|
|
46
|
+
* @param _packetMsgValues An array of associated message values for each packet.
|
|
47
|
+
* @return packets An array of InboundPacket structs representing the decoded packets.
|
|
48
|
+
*/
|
|
49
|
+
function decode(
|
|
50
|
+
bytes[] calldata _packets,
|
|
51
|
+
uint256[] memory _packetMsgValues
|
|
52
|
+
) internal pure returns (InboundPacket[] memory packets) {
|
|
53
|
+
packets = new InboundPacket[](_packets.length);
|
|
54
|
+
for (uint256 i = 0; i < _packets.length; i++) {
|
|
55
|
+
bytes calldata packet = _packets[i];
|
|
56
|
+
packets[i] = PacketDecoder.decode(packet);
|
|
57
|
+
// @dev Allows the verifier to specify the msg.value that gets passed in lzReceive.
|
|
58
|
+
packets[i].value = _packetMsgValues[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract artifacts are the product of this package: read them by path, e.g.
|
|
3
|
+
* `@layerzerolabs/protocol-v2-oapp-evm-contracts/artifacts/contracts/<Source>.sol/<Contract>.json`
|
|
4
|
+
* (`artifacts-zk/` for zkSync, `artifacts-tron/` for Tron).
|
|
5
|
+
*/
|
|
6
|
+
export declare const PACKAGE_NAME = "@layerzerolabs/protocol-v2-oapp-evm-contracts";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,kDAAkD,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["PACKAGE_NAME"],"mappings":";AAKO,IAAMA,YAAAA,GAAe","file":"index.js","sourcesContent":["/**\n * The contract artifacts are the product of this package: read them by path, e.g.\n * `@layerzerolabs/protocol-v2-oapp-evm-contracts/artifacts/contracts/<Source>.sol/<Contract>.json`\n * (`artifacts-zk/` for zkSync, `artifacts-tron/` for Tron).\n */\nexport const PACKAGE_NAME = '@layerzerolabs/protocol-v2-oapp-evm-contracts';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@layerzerolabs/protocol-v2-oapp-evm-contracts",
|
|
3
|
+
"version": "1.2.95",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Copied from @layerzerolabs/lz-evm-oapp-v2 in the old LayerZero-Labs/monorepo",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./artifacts/*": "./artifacts/*",
|
|
15
|
+
"./artifacts-zk/*": "./artifacts-zk/*",
|
|
16
|
+
"./artifacts-tron/*": "./artifacts-tron/*",
|
|
17
|
+
"./contracts/*": "./contracts/*",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"artifacts/contracts/**/!(*.dbg).json",
|
|
25
|
+
"artifacts-zk/contracts/**/!(*.dbg).json",
|
|
26
|
+
"artifacts-tron/contracts/**/!(*.dbg).json",
|
|
27
|
+
"contracts/**/*",
|
|
28
|
+
"dist/**/*"
|
|
29
|
+
],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@layerzerolabs/hardhat-tron": "3.0.168",
|
|
32
|
+
"@layerzerolabs/lz-evm-messagelib-v2": "npm:@layerzerolabs/protocol-v2-messagelib-evm-contracts@1.2.95",
|
|
33
|
+
"@layerzerolabs/lz-evm-protocol-v2": "npm:@layerzerolabs/protocol-v2-evm-contracts@1.2.95",
|
|
34
|
+
"@layerzerolabs/lz-evm-v1-0.7": "npm:@layerzerolabs/protocol-v1-0.7-evm-contracts@1.2.95",
|
|
35
|
+
"@layerzerolabs/toolbox-foundry": "^0.1.13",
|
|
36
|
+
"@layerzerolabs/tsup-configuration": "1.2.95",
|
|
37
|
+
"@layerzerolabs/typescript-configuration": "1.2.95",
|
|
38
|
+
"@layerzerolabs/vm-tooling-evm": "1.2.95",
|
|
39
|
+
"@matterlabs/hardhat-zksync-solc": "1.3.2",
|
|
40
|
+
"@openzeppelin/contracts": "4.9.5",
|
|
41
|
+
"@openzeppelin/contracts-upgradeable": "4.9.5",
|
|
42
|
+
"hardhat-deploy": "0.12.4",
|
|
43
|
+
"solidity-bytes-utils": "npm:@layerzerolabs/solidity-bytes-utils@0.8.0",
|
|
44
|
+
"tsup": "^8.4.0"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "restricted",
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
49
|
+
},
|
|
50
|
+
"externalRepoConfig": {
|
|
51
|
+
"targets": [
|
|
52
|
+
"everdawn-externalization"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "pnpm compile:evm && pnpm compile:zksync && pnpm compile:tron && tsup",
|
|
57
|
+
"clean": "rm -rf ./node_modules .turbo ./dist && pnpm generated:clean",
|
|
58
|
+
"compile:evm": "pnpm lz-tool hardhat compile --config ./hardhat.config.cjs",
|
|
59
|
+
"compile:tron": "pnpm lz-tool hardhat compile --config ./hardhat.config.cjs --network tron-mainnet",
|
|
60
|
+
"compile:zksync": "pnpm lz-tool hardhat compile --config ./hardhat.config.cjs --network zksync-mainnet",
|
|
61
|
+
"generated:clean": "rm -rf ./artifacts* ./hh-cache* ./out ./cache",
|
|
62
|
+
"lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)",
|
|
63
|
+
"test": "pnpm lz-tool forge test",
|
|
64
|
+
"test:snapshot:check": "pnpm exec turbo-snapshot check",
|
|
65
|
+
"test:snapshot:update": "pnpm exec turbo-snapshot update"
|
|
66
|
+
}
|
|
67
|
+
}
|