@rootzero/contracts 0.7.0 → 0.7.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/core/Operation.sol +1 -1
- package/package.json +1 -1
- package/peer/AssetPull.sol +31 -30
- package/queries/Base.sol +1 -1
package/core/Operation.sol
CHANGED
|
@@ -15,7 +15,7 @@ error FailedCall(address addr, bytes4 selector, bytes err);
|
|
|
15
15
|
/// @notice Shared base for command and peer contracts.
|
|
16
16
|
/// Provides convenience wrappers for cursor construction, quotient validation,
|
|
17
17
|
/// and trusted inter-node calls. Inherits access control from `AccessControl`.
|
|
18
|
-
abstract contract OperationBase is
|
|
18
|
+
abstract contract OperationBase is CursorBase, AccessControl {
|
|
19
19
|
/// @notice Return the host node ID corresponding to the current caller.
|
|
20
20
|
/// @dev Encodes `msg.sender` as a host ID using the local-chain host layout.
|
|
21
21
|
/// @return Host node ID for `msg.sender`.
|
package/package.json
CHANGED
package/peer/AssetPull.sol
CHANGED
|
@@ -9,33 +9,34 @@ string constant NAME = "peerAssetPull";
|
|
|
9
9
|
using Cursors for Cur;
|
|
10
10
|
|
|
11
11
|
/// @title PeerAssetPull
|
|
12
|
-
/// @notice Peer that pulls
|
|
13
|
-
/// Each
|
|
14
|
-
/// is derived from `msg.sender`. Restricted to trusted peers.
|
|
15
|
-
abstract contract PeerAssetPull is PeerBase {
|
|
16
|
-
uint internal immutable peerAssetPullId = peerId(NAME);
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
emit Peer(host, NAME, Schemas.
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/// @notice Override to process one incoming asset pull request from a remote host.
|
|
23
|
-
/// @param peer Host node ID derived from the caller address.
|
|
24
|
-
/// @param asset Requested asset identifier.
|
|
25
|
-
/// @param meta Requested asset metadata slot.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
12
|
+
/// @notice Peer that pulls requested asset amounts from a remote host into this one.
|
|
13
|
+
/// Each AMOUNT block in the request calls `peerAssetPull(peer, asset, meta, amount)`, where `peer`
|
|
14
|
+
/// is derived from `msg.sender`. Restricted to trusted peers.
|
|
15
|
+
abstract contract PeerAssetPull is PeerBase {
|
|
16
|
+
uint internal immutable peerAssetPullId = peerId(NAME);
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
emit Peer(host, NAME, Schemas.Amount, peerAssetPullId, false);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// @notice Override to process one incoming amount-based asset pull request from a remote host.
|
|
23
|
+
/// @param peer Host node ID derived from the caller address.
|
|
24
|
+
/// @param asset Requested asset identifier.
|
|
25
|
+
/// @param meta Requested asset metadata slot.
|
|
26
|
+
/// @param amount Requested amount in the asset's native units.
|
|
27
|
+
function peerAssetPull(uint peer, bytes32 asset, bytes32 meta, uint amount) internal virtual;
|
|
28
|
+
|
|
29
|
+
/// @notice Execute the asset-pull peer call.
|
|
30
|
+
function peerAssetPull(bytes calldata request) external onlyPeer returns (bytes memory) {
|
|
31
|
+
(Cur memory assets, , ) = cursor(request, 1);
|
|
32
|
+
uint peer = caller();
|
|
33
|
+
|
|
34
|
+
while (assets.i < assets.bound) {
|
|
35
|
+
(bytes32 asset, bytes32 meta, uint amount) = assets.unpackAmount();
|
|
36
|
+
peerAssetPull(peer, asset, meta, amount);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
assets.complete();
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
}
|
package/queries/Base.sol
CHANGED
|
@@ -21,7 +21,7 @@ function encodeQueryCall(uint target, bytes calldata request) pure returns (byte
|
|
|
21
21
|
/// @notice Abstract base for rootzero query contracts.
|
|
22
22
|
/// Queries are view-only entry points that consume a block-stream request and
|
|
23
23
|
/// return a block-stream response.
|
|
24
|
-
abstract contract QueryBase is
|
|
24
|
+
abstract contract QueryBase is CursorBase, HostBound, QueryEvent {
|
|
25
25
|
|
|
26
26
|
/// @notice Derive the deterministic node ID for a named query on this contract.
|
|
27
27
|
/// The ID encodes the ABI selector of `name(bytes)` and `address(this)`,
|