Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions contracts/contracts/ccip/ccipsend_executor/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import "../fee_quoter/types"
import "@stdlib/gas-payments"

const CONTRACT_VERSION = "1.6.0";
const FACILITY_NAME = "com.chainlink.ton.ccip.CCIPSendExecutor";

fun onInternalMessage(in: InMessage) {
val msg = lazy CCIPSendExecutor_InMessage.fromSlice(in.body);
Expand Down Expand Up @@ -153,11 +152,11 @@ fun CCIPSendExecutor<T>.exitWithError(self, error: uint256) {
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.CCIPSendExecutor", CONTRACT_VERSION);
return (CCIPSendExecutor_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.CCIPSendExecutor"));
return CCIPSendExecutor_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ccip/ccipsend_executor/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "types"

enum CCIPSendExecutor_Error {
StateNotExpected = 43600 // Facility ID * 100
StateNotExpected = CCIPSendExecutor_FACILITY_ID * 100
Unauthorized
InsufficientFunds
InsufficientFee
Expand Down
6 changes: 4 additions & 2 deletions contracts/contracts/ccip/ccipsend_executor/types.tolk
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import "../onramp/messages.tolk";
import "../../deployable/types"
import "../../lib/deployable/namespace"

const CCIPSendExecutor_FACILITY_NAME = "com.chainlink.ton.ccip.CCIPSendExecutor";
// getFacilityId(stringCrc32(CCIPSendExecutor_FACILITY_NAME));
const CCIPSendExecutor_FACILITY_ID = 436;

type CCIPSendExecutor_ID = uint224

Expand Down
5 changes: 2 additions & 3 deletions contracts/contracts/ccip/fee_quoter/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import "../../lib/funding/withdrawable"
import "../../lib/versioning/upgradeable"

const CONTRACT_VERSION = "1.6.0";
const FACILITY_NAME = "com.chainlink.ton.ccip.FeeQuoter";
const RESERVE = ton("1"); // TODO: set correct value

fun onInternalMessage(in: InMessage) {
Expand Down Expand Up @@ -640,11 +639,11 @@ get fun pendingOwner(): address? {
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.FeeQuoter", CONTRACT_VERSION);
return (FeeQuoter_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.FeeQuoter"));
return FeeQuoter_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ccip/fee_quoter/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "types"

enum FeeQuoter_Error {
UnsupportedChainFamilySelector = 24800 // Facility ID * 100
UnsupportedChainFamilySelector = FeeQuoter_FACILITY_ID * 100
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer having the entire value here. That way you can just search for 24800 and go straight to the Error enum. Just personal preference though, i am not against this change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, but if you get error 24801, the query fails. You still have to search for '248'. It is true though that it would take you to the error enum instead of the FACILITY_ID.

GasLimitTooHigh
ExtraArgOutOfOrderExecutionMustBeTrue
InvalidExtraArgsData
Expand Down
4 changes: 4 additions & 0 deletions contracts/contracts/ccip/fee_quoter/types.tolk
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import "../../lib/utils"

const FeeQuoter_FACILITY_NAME = "com.chainlink.ton.ccip.FeeQuoter";
// getFacilityId(stringCrc32(FeeQuoter_FACILITY_NAME));
const FeeQuoter_FACILITY_ID = 248;

struct TimestampedPrice {
value: uint224;
timestamp: uint32;
Expand Down
5 changes: 3 additions & 2 deletions contracts/contracts/ccip/merkle_root/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "../../deployable/types.tolk"
import "../receive_executor/storage"
import "../router/storage"
import "../../lib/funding/withdrawable"
import "types"

// MerkleRoot contract
// Root is commited on Commit Reports and the existence of this contract is used to validate Execute Reports
Expand Down Expand Up @@ -108,11 +109,11 @@ fun onInitExecute(mutate st: MerkleRoot_Storage, msg: MerkleRoot_Validate) {
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.MerkleRoot", CONTRACT_VERSION);
return (MerkleRoot_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.MerkleRoot"));
return MerkleRoot_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ccip/merkle_root/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "types"

enum MerkleRoot_Error {
AlreadyExecuted = 47900 // Facility ID * 100
AlreadyExecuted = MerkleRoot_FACILITY_ID * 100
NotOwner
ManualExecutionNotYetEnabled
SkippedAlreadyExecutedMessage
Expand Down
3 changes: 3 additions & 0 deletions contracts/contracts/ccip/merkle_root/types.tolk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const MerkleRoot_FACILITY_NAME = "com.chainlink.ton.ccip.MerkleRoot";
// getFacilityId(stringCrc32(MerkleRoot_FACILITY_NAME));
const MerkleRoot_FACILITY_ID = 479;
4 changes: 2 additions & 2 deletions contracts/contracts/ccip/offramp/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,11 @@ get fun pendingOwner(): address? {
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.OffRamp", CONTRACT_VERSION);
return (OffRamp_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.OffRamp"));
return OffRamp_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ccip/offramp/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "types"

enum Error {
MessageNotFromOwnedContract = 8400
MessageNotFromOwnedContract = OffRamp_FACILITY_ID * 100
SourceChainNotEnabled
EmptyExecutionReport
InvalidMessageDestChainSelector
Expand Down
5 changes: 4 additions & 1 deletion contracts/contracts/ccip/offramp/types.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import "../common/types"
import "../fee_quoter/types"
import "../../lib/utils"
import "../../deployable/types"
import "../../lib/deployable/namespace"

const OffRamp_FACILITY_NAME = "com.chainlink.ton.ccip.OffRamp";
// getFacilityId(stringCrc32(OffRamp_FACILITY_NAME));
const OffRamp_FACILITY_ID = 84;

struct ExecutionReport {
sourceChainSelector: uint64;
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/ccip/onramp/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,11 @@ get fun sendExecutorCodeHash(): uint256 {
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.OnRamp", CONTRACT_VERSION);
return (OnRamp_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.OnRamp"));
return OnRamp_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/ccip/onramp/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "../../lib/utils"
import "types"

enum Error {
UnknownDestChainSelector = 18100 // Facility ID * 100
UnknownDestChainSelector = OnRamp_FACILITY_ID * 100
Unauthorized
SenderNotAllowed
InvalidConfig
Expand Down
4 changes: 4 additions & 0 deletions contracts/contracts/ccip/onramp/types.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import "../ccipsend_executor/types"
import "../../deployable/types"
import "../../lib/deployable/namespace"

const OnRamp_FACILITY_NAME = "com.chainlink.ton.ccip.OnRamp";
// getFacilityId(stringCrc32(OnRamp_FACILITY_NAME));
const OnRamp_FACILITY_ID = 181;

struct OnRamp_DestChainConfig {
router: address; // Local router address that is allowed to send messages to the destination chain.
sequenceNumber: uint64;
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/ccip/receive_executor/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ fun onCCIPReceiveBounced(mutate st: ReceiveExecutor_Storage, msg: ReceiveExecuto
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.ReceiveExecutor", CONTRACT_VERSION);
return (ReceiveExecutor_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.ReceiveExecutor"));
return ReceiveExecutor_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ccip/receive_executor/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "types"

enum Error {
StateIsNotUntouched = 33800 // Facility ID * 100
StateIsNotUntouched = ReceiveExecutor_FACILITY_ID * 100
UpdatingStateOfNonExecutedMessage
NotificationFromInvalidReceiver
Unauthorized
Expand Down
4 changes: 4 additions & 0 deletions contracts/contracts/ccip/receive_executor/types.tolk
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const ReceiveExecutor_FACILITY_NAME = "com.chainlink.ton.ccip.ReceiveExecutor";
// getFacilityId(stringCrc32(ReceiveExecutor_FACILITY_NAME));
const ReceiveExecutor_FACILITY_ID = 338;

// State stores the general state machine indicating which phase we're in
enum ReceiveExecutor_MessageState {
Untouched = 0
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/ccip/router/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,11 @@ get fun rmn_pendingOwner(): address? {
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.Router", CONTRACT_VERSION);
return (Router_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.Router"));
return Router_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ccip/router/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "types"

enum Router_Error {
DestChainNotEnabled = 49600
DestChainNotEnabled = Router_FACILITY_ID * 100
SourceChainNotEnabled
SenderIsNotOffRamp
OffRampNotSetForSelector
Expand Down
6 changes: 4 additions & 2 deletions contracts/contracts/ccip/router/types.tolk
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import "../common/types"
import "../fee_quoter/types"
import "../../lib/utils"

const Router_FACILITY_NAME = "com.chainlink.ton.ccip.Router";
// getFacilityId(stringCrc32(Router_FACILITY_NAME));
const Router_FACILITY_ID = 496;

struct OnRamps {
destChainSelectors: SnakedCell<uint64>;
onRamp: address;
Expand Down
5 changes: 3 additions & 2 deletions contracts/contracts/ccip/test/receiver/contract.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "../../../lib/receiver/types";
import "../../../lib/utils";
import "../../router/messages"
import "../../../lib/access/ownable_2step"
import "types"

const CONTRACT_VERSION = "1.6.0";

Expand Down Expand Up @@ -113,11 +114,11 @@ get fun getBehavior(): int {
}

get fun typeAndVersion(): (slice, slice) {
return ("com.chainlink.ton.ccip.test.Receiver", CONTRACT_VERSION);
return (TestReceiver_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.test.Receiver"));
return TestReceiver_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
Expand Down
4 changes: 3 additions & 1 deletion contracts/contracts/ccip/test/receiver/errors.tolk
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "types"

enum Error {
Unauthorized = 34600 // Facility ID * 100
Unauthorized = TestReceiver_FACILITY_ID * 100
Rejected
}
3 changes: 3 additions & 0 deletions contracts/contracts/ccip/test/receiver/types.tolk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const TestReceiver_FACILITY_NAME = "com.chainlink.ton.ccip.test.Receiver";
// getFacilityId(stringCrc32(TestReceiver_FACILITY_NAME));
const TestReceiver_FACILITY_ID = 346;
17 changes: 16 additions & 1 deletion contracts/contracts/deployable/contract.tolk
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import "types"
import "../lib/utils"

const CONTRACT_VERSION = "1.0.0";

fun onInternalMessage(in: InMessage) {
val st = Deployable<RemainingBitsAndRefs>.load();
assert(in.senderAddress == st.owner) throw ERROR_NOT_OWNER;
assert(in.senderAddress == st.owner) throw Deployable_Error.NotOwner as int;
val inMsg = lazy Deployable_InMessage.fromSlice(in.body);
match (inMsg) {
Deployable_Initialize => {
Expand All @@ -22,3 +25,15 @@ fun onInternalMessage(in: InMessage) {
}
}
}

get fun typeAndVersion(): (slice, slice) {
return (Deployable_FACILITY_NAME, CONTRACT_VERSION);
}

get fun facilityId(): uint16 {
return Deployable_FACILITY_ID;
}

get fun errorCode(local: uint16): uint16 {
return getErrorCode(stringCrc32("com.chainlink.ton.ccip.Deployable"), local);
}
12 changes: 9 additions & 3 deletions contracts/contracts/deployable/types.tolk
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import "../lib/utils"

const Deployable_FACILITY_NAME = "com.chainlink.ton.ccip.Deployable";
// getFacilityId(stringCrc32("Deployable"))
const Deployable_FACILITY_ID = 374;

struct Deployable<T> {
owner: address;
id: T // builder on serialize, RemainingBitsAndRefs on deserialize
Expand Down Expand Up @@ -31,6 +37,6 @@ struct Deployable_Message {
body: cell;
}

// facilityId(crc32('Deployable_ErrorNotOwner')) * 100
const ERROR_NOT_OWNER: int = 37400;

enum Deployable_Error {
NotOwner = Deployable_FACILITY_ID * 100
}
2 changes: 1 addition & 1 deletion contracts/contracts/examples/counter.tolk
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fun onInternalMessage(in: InMessage) {
if (!msgHandled) {
// If the message was not handled
// ignore empty messages, "wrong opcode" for others
assert (in.body.isEmpty()) throw ERROR_WRONG_OP;
assert (in.body.isEmpty()) throw 0xFFFF;
}
}
}
Expand Down
Loading
Loading