Skip to content

Commit 59e8bb8

Browse files
Update metadata retrieval and deploy script
1 parent 05a243f commit 59e8bb8

File tree

2 files changed

+67
-7
lines changed

2 files changed

+67
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {DeployFunction} from 'hardhat-deploy/types';
2+
import {HardhatRuntimeEnvironment} from 'hardhat/types';
3+
import {DEPLOY_TAGS} from '../../hardhat.config';
4+
5+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
6+
const {deployments, getNamedAccounts} = hre;
7+
const {deploy} = deployments;
8+
const {
9+
deployer,
10+
treasury,
11+
commonRoyaltyReceiver,
12+
backendAuthWallet,
13+
sandAdmin,
14+
upgradeAdmin,
15+
} = await getNamedAccounts();
16+
17+
const TRUSTED_FORWARDER = await deployments.get('SandboxForwarder');
18+
const sandContract = await deployments.get('PolygonSand');
19+
const BASE_URL = 'https://contracts.sandbox.game';
20+
21+
await deploy('GamePasses', {
22+
from: deployer,
23+
contract:
24+
'@sandbox-smart-contracts/game-passes/contracts/GamePasses.sol:GamePasses',
25+
proxy: {
26+
owner: upgradeAdmin,
27+
proxyContract: 'OpenZeppelinTransparentProxy',
28+
execute: {
29+
methodName: 'initialize',
30+
args: [
31+
{
32+
baseURI: BASE_URL,
33+
royaltyReceiver: commonRoyaltyReceiver,
34+
royaltyFeeNumerator: 500, // 5%
35+
admin: sandAdmin,
36+
operator: deployer,
37+
signer: backendAuthWallet,
38+
paymentToken: sandContract.address,
39+
trustedForwarder: TRUSTED_FORWARDER.address,
40+
defaultTreasury: treasury,
41+
owner: sandAdmin,
42+
},
43+
],
44+
},
45+
upgradeIndex: 0,
46+
},
47+
log: true,
48+
});
49+
};
50+
export default func;
51+
52+
func.tags = [
53+
'GamePass',
54+
'GamePass_deploy',
55+
DEPLOY_TAGS.L2,
56+
DEPLOY_TAGS.L2_PROD,
57+
DEPLOY_TAGS.L2_TEST,
58+
];
59+
func.dependencies = [
60+
'OperatorFilterAssetSubscription_deploy',
61+
'TRUSTED_FORWARDER_V2',
62+
'RoyaltyManager_deploy',
63+
];

packages/game-passes/contracts/GamePasses.sol

+4-7
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,11 @@ contract GamePasses is
311311
* - trustedForwarder: Address of the trusted meta-transaction forwarder.
312312
* - defaultTreasury: Address of the default treasury wallet.
313313
* - owner: Address that will be set as the internal owner.
314-
* - sandContract: Address of the SAND contract.
315314
*/
316315
function initialize(InitParams calldata params) external initializer {
317316
__ERC2771Handler_init(params.trustedForwarder);
318317
__AccessControl_init();
319-
__ERC1155_init(params.baseURI);
318+
__ERC1155_init("");
320319
__ERC1155Supply_init();
321320
__ERC2981_init();
322321
__Pausable_init();
@@ -336,7 +335,6 @@ contract GamePasses is
336335

337336
CoreStorage storage cs = _coreStorage();
338337
cs.paymentToken = params.paymentToken;
339-
cs.baseURI = params.baseURI;
340338
cs.defaultTreasuryWallet = params.defaultTreasury;
341339
cs.internalOwner = params.owner;
342340
cs.DOMAIN_SEPARATOR = keccak256(
@@ -1074,12 +1072,11 @@ contract GamePasses is
10741072
/**
10751073
* @notice Returns the metadata URI for a specific token ID
10761074
* @param tokenId ID of the token to get URI for
1077-
* @dev Constructs the URI by concatenating baseURI + tokenId + ".json"
1078-
* @dev Can be overridden by derived contracts to implement different URI logic
1079-
* @return string The complete URI for the token metadata
1075+
* @dev Returns the token-specific metadata string stored in the token configuration
1076+
* @return string The metadata URI for the token
10801077
*/
10811078
function uri(uint256 tokenId) public view virtual override returns (string memory) {
1082-
return string(abi.encodePacked(_coreStorage().baseURI, tokenId.toString(), ".json"));
1079+
return _tokenStorage().tokenConfigs[tokenId].metadata;
10831080
}
10841081

10851082
/**

0 commit comments

Comments
 (0)