Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 1x 5x 3x 2x 2x 2x 2x 2x 2x 2x 2x | import { OP_TYPES } from "../../constants";
import { Change } from "../../../rmrk1.0.0/changelog";
import { Remark } from "../remark";
import { Send } from "../../../rmrk1.0.0/classes/send";
import { NFT } from "../../..";
export const sendInteraction = (
remark: Remark,
sendEntity: Send,
nft?: NFT
): void => {
if (!nft) {
throw new Error(
`[${OP_TYPES.SEND}] Attempting to send non-existant NFT ${sendEntity.id}`
);
}
Iif (nft.burned != "") {
throw new Error(
`[${OP_TYPES.SEND}] Attempting to send burned NFT ${sendEntity.id}`
);
}
// Check if allowed to issue send - if owner == caller
Iif (nft.owner != remark.caller) {
throw new Error(
`[${OP_TYPES.SEND}] Attempting to send non-owned NFT ${sendEntity.id}, real owner: ${nft.owner}`
);
}
Iif (nft.transferable === 0 || nft.transferable >= remark.block) {
throw new Error(
`[${OP_TYPES.SEND}] Attempting to send non-transferable NFT ${sendEntity.id}.`
);
}
nft.addChange({
field: "owner",
old: nft.owner,
new: sendEntity.recipient,
caller: remark.caller,
block: remark.block,
} as Change);
nft.owner = sendEntity.recipient;
// Cancel LIST, if any
Eif (nft.forsale > BigInt(0)) {
nft.addChange({
field: "forsale",
old: nft.forsale,
new: BigInt(0),
caller: remark.caller,
block: remark.block,
} as Change);
nft.forsale = BigInt(0);
}
};
|