Smart Contract

TransactionsRegistry

A.e81193c424cfd3fb.TransactionsRegistry

Deployed

2d ago
Feb 26, 2026, 01:49:14 PM UTC

Dependents

0 imports
1/**
2Contract to register transactions that have been executed from admin accounts.
3
4Old functionality is kept in this contract for backwards compatibility,
5related to teleporter transactions from the Doodles Drop Ethereum contract.
6
7New transactions should be registered using the generic methods.
8
9A registry is composed from a name, arguments and a value.
10The name identifies the type of transaction. For example "mint-doodle"
11The arguments are unique identifiers for each transaction.
12For example, the address of the receiver of the minted doodle.
13The value is any variable that is related to the transaction.
14For example, the name of the minted doodle.
15*/
16access(all) contract TransactionsRegistry {
17	access(all) event Register(name: String, args: [String], value: String)
18
19	// Old event for backwards compatibility in teleporter
20	access(all) event TransactionRegistered(key: String, transactionId: String)
21
22	access(self) let registry: {String: String}
23
24	access(self) let extra: {String: AnyStruct}
25
26	access(all) fun isRegistered(name: String, args: [String]): Bool {
27		return self.getRegistryValue(name: name, args: args) != nil
28	}
29
30	access(all) fun getRegistryValue(name: String, args: [String]): String? {
31		let key: String = self.getKey(name: name, args: args)
32		return self.registry[key]
33	}
34
35	access(account) fun register(name: String, args: [String], value: String) {
36		let key: String = self.getKey(name: name, args: args)
37		if self.registry[key] != nil {
38			panic("Transaction already registered")
39		}
40		self.registry[key] = value
41		emit Register(name: name, args: args, value: value)
42	}
43
44	access(self) fun getKey(name: String, args: [String]): String {
45		var key: String = name
46		for arg in args {
47			key = key.concat("-").concat(arg)
48		}
49		return key
50	}
51
52	// Only for backwards compatibility. Use the generic methods for new transactions.
53
54	// Teleporter from Ethereum Doodles Drops to Wearables Mint
55
56	access(all) fun getRegistryDoodlesDropsWearablesMint(packTypeId: UInt64, packId: UInt64): String? {
57		return self.getRegistryValue(
58			name: "doodles-drops-wearables-mint",
59			args: [packTypeId.toString(), packId.toString()]
60		)
61	}
62
63	access(account) fun registerDoodlesDropsWearablesMint(packTypeId: UInt64, packId: UInt64, transactionId: String) {
64		self.register(
65			name: "doodles-drops-wearables-mint",
66			args: [packTypeId.toString(), packId.toString()],
67			value: transactionId
68		)
69	}
70
71	// Teleporter from Ethereum Doodles Drops to Redeemables Mint
72
73	access(all) fun getRegistryDoodlesDropsRedeemablesMint(packTypeId: UInt64, packId: UInt64): String? {
74		return self.getRegistryValue(
75			name: "doodles-drops-redeemables-mint",
76			args: [packTypeId.toString(), packId.toString()],
77		)
78	}
79
80	access(account) fun registerDoodlesDropsRedeemablesMint(packTypeId: UInt64, packId: UInt64, transactionId: String) {
81		self.register(
82			name: "doodles-drops-redeemables-mint",
83			args: [packTypeId.toString(), packId.toString()],
84			value: transactionId
85		)
86	}
87
88	init() {
89		self.registry = {}
90		self.extra = {}
91	}
92
93}
94