@rootzero/contracts 0.7.0 → 0.7.1
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/package.json +1 -1
- package/peer/AssetPull.sol +31 -30
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
|
+
}
|