File tree Expand file tree Collapse file tree 4 files changed +193
-0
lines changed Expand file tree Collapse file tree 4 files changed +193
-0
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ pragma solidity ^ 0.8.0 ;
3+
4+ import "./interface/IAppURI.sol " ;
5+
6+ /**
7+ * Thirdweb's `AppURI` is a contract extension for any contract
8+ * that wants to add an official App URI that follows the appUri spec
9+ *
10+ */
11+
12+ abstract contract AppURI is IAppURI {
13+ /// @dev appURI
14+ string public override appURI;
15+
16+ /// @dev Lets a contract admin set the URI for app metadata.
17+ function setAppURI (string memory _uri ) public override {
18+ if (! _canSetAppURI ()) {
19+ revert ("Not authorized " );
20+ }
21+
22+ _setupAppURI (_uri);
23+ }
24+
25+ /// @dev Lets a contract admin set the URI for app metadata.
26+ function _setupAppURI (string memory _uri ) internal {
27+ string memory prevURI = appURI;
28+ appURI = _uri;
29+
30+ emit AppURIUpdated (prevURI, _uri);
31+ }
32+
33+ /// @dev Returns whether appUri can be set in the given execution context.
34+ function _canSetAppURI () internal view virtual returns (bool );
35+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+ pragma solidity ^ 0.8.0 ;
3+
4+ /**
5+ * Thirdweb's `AppURI` is a contract extension for any base contracts. It lets you set a metadata URI
6+ * for you contract.
7+ *
8+ */
9+
10+ interface IAppURI {
11+ /// @dev Returns the metadata URI of the contract.
12+ function appURI () external view returns (string memory );
13+
14+ /**
15+ * @dev Sets contract URI for the storefront-level metadata of the contract.
16+ * Only module admin can call this function.
17+ */
18+ function setAppURI (string calldata _uri ) external ;
19+
20+ /// @dev Emitted when the contract URI is updated.
21+ event AppURIUpdated (string prevURI , string newURI );
22+ }
Original file line number Diff line number Diff line change 1+ # AppURI
2+
3+
4+
5+
6+
7+ Thirdweb' ; s ` AppURI ` is a contract extension for any contract that wants to add an official App URI that follows the appUri spec
8+
9+
10+
11+ ## Methods
12+
13+ ### appURI
14+
15+ ``` solidity
16+ function appURI() external view returns (string)
17+ ```
18+
19+
20+
21+ * appURI*
22+
23+
24+ #### Returns
25+
26+ | Name | Type | Description |
27+ | ---| ---| ---|
28+ | _ 0 | string | undefined |
29+
30+ ### setAppURI
31+
32+ ``` solidity
33+ function setAppURI(string _uri) external nonpayable
34+ ```
35+
36+
37+
38+ * Lets a contract admin set the URI for app metadata.*
39+
40+ #### Parameters
41+
42+ | Name | Type | Description |
43+ | ---| ---| ---|
44+ | _ uri | string | undefined |
45+
46+
47+
48+ ## Events
49+
50+ ### AppURIUpdated
51+
52+ ``` solidity
53+ event AppURIUpdated(string prevURI, string newURI)
54+ ```
55+
56+
57+
58+
59+
60+ #### Parameters
61+
62+ | Name | Type | Description |
63+ | ---| ---| ---|
64+ | prevURI | string | undefined |
65+ | newURI | string | undefined |
66+
67+
68+
Original file line number Diff line number Diff line change 1+ # IAppURI
2+
3+
4+
5+
6+
7+ Thirdweb' ; s ` AppURI ` is a contract extension for any base contracts. It lets you set a metadata URI for you contract.
8+
9+
10+
11+ ## Methods
12+
13+ ### appURI
14+
15+ ``` solidity
16+ function appURI() external view returns (string)
17+ ```
18+
19+
20+
21+ * Returns the metadata URI of the contract.*
22+
23+
24+ #### Returns
25+
26+ | Name | Type | Description |
27+ | ---| ---| ---|
28+ | _ 0 | string | undefined |
29+
30+ ### setAppURI
31+
32+ ``` solidity
33+ function setAppURI(string _uri) external nonpayable
34+ ```
35+
36+
37+
38+ * Sets contract URI for the storefront-level metadata of the contract. Only module admin can call this function.*
39+
40+ #### Parameters
41+
42+ | Name | Type | Description |
43+ | ---| ---| ---|
44+ | _ uri | string | undefined |
45+
46+
47+
48+ ## Events
49+
50+ ### AppURIUpdated
51+
52+ ``` solidity
53+ event AppURIUpdated(string prevURI, string newURI)
54+ ```
55+
56+
57+
58+ * Emitted when the contract URI is updated.*
59+
60+ #### Parameters
61+
62+ | Name | Type | Description |
63+ | ---| ---| ---|
64+ | prevURI | string | undefined |
65+ | newURI | string | undefined |
66+
67+
68+
You can’t perform that action at this time.
0 commit comments