Skip to content

Commit

Permalink
fix nft collection
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-hash committed Jan 5, 2025
1 parent 1ffdf36 commit 69a847b
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 39 deletions.
10 changes: 5 additions & 5 deletions contracts/.project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"fullNodeVersion": "v3.8.8",
"fullNodeVersion": "v3.10.0",
"compilerOptionsUsed": {
"ignoreUnusedConstantsWarnings": false,
"ignoreUnusedVariablesWarnings": false,
Expand All @@ -13,9 +13,9 @@
"infos": {
"BurnerNFT": {
"sourceFile": "nftBurnerTemplate.ral",
"sourceCodeHash": "72c2cae349a7e1317f5ffb23ea445f347a4a53c6e8dc42ad78da660a0d127513",
"sourceCodeHash": "cbe6ce771aa99cc3df4f2607adb87dae7234921675d48287351437546a40314a",
"bytecodeDebugPatch": "",
"codeHashDebug": "de86ba673a50975a76b894d00590f4c907220136a3c32573024885245e6f5b75"
"codeHashDebug": "80d0fff0dd5aba768a1fa0b2d16bad836f1eccef91704ede23970fea92a49a26"
},
"INFT": {
"sourceFile": "../../node_modules/@alephium/web3/std/nft_interface.ral",
Expand All @@ -31,9 +31,9 @@
},
"TokenFurnace": {
"sourceFile": "token.ral",
"sourceCodeHash": "383619623ad1a9fa8913b16a86d52f2b8ef8361631211891c398789a1a2059b4",
"sourceCodeHash": "7f01f08a14cadddd689417d8c7c9221d1944ba558cf1209982a90c3b01fed6de",
"bytecodeDebugPatch": "",
"codeHashDebug": "d0e8cba96b5dfdb2fd41df2553d98529bacd65e3ec91d424aea8e07292c2b3e3"
"codeHashDebug": "b1fc1809498587ee52f79c339c41533972a701865f38a1e9e05ab1dcf31b64e2"
}
}
}
9 changes: 6 additions & 3 deletions contracts/artifacts/BurnerNFT.ral.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
{
"version": "v3.8.5",
"version": "v3.10.0",
"name": "BurnerNFT",
"bytecode": "050240db40e6010000000115144025646174613a6170706c69636174696f6e2f6a736f6e2c7b226e616d65223a20224275726e20ce01894414403b222c202261747472696275746573223a205b7b2274726169745f74797065223a2022416d6f756e74206275726e6564222c202276616c7565223a2044ce0389441440287d2c207b2274726169745f74797065223a202254696d657374616d70222c202276616c7565223a20445689441440287d2c207b2274726169745f74797065223a2022546f6b656e204964222c202276616c7565223a202244ce02441404227d5d7d4402010000000203ce00ce0102",
"codeHash": "de86ba673a50975a76b894d00590f4c907220136a3c32573024885245e6f5b75",
"bytecode": "0602410a4115010000000119144025646174613a6170706c69636174696f6e2f6a736f6e2c7b226e616d65223a20224275726e20ce01894414403b222c202261747472696275746573223a205b7b2274726169745f74797065223a2022416d6f756e74206275726e6564222c202276616c7565223a2044ce0389441440287d2c207b2274726169745f74797065223a202254696d657374616d70222c202276616c7565223a20445689441440287d2c207b2274726169745f74797065223a2022546f6b656e204964222c202276616c7565223a202244ce0244144028227d2c20207b2274726169745f74797065223a20224275726e6572222c202276616c7565223a202244ce04441404227d5d7d4402010000000203ce00ce0102",
"codeHash": "80d0fff0dd5aba768a1fa0b2d16bad836f1eccef91704ede23970fea92a49a26",
"fieldsSig": {
"names": [
"collectionId",
"nftIndex",
"tokenIdBurned",
"amountBurned",
"burnedBy",
"__stdInterfaceId"
],
"types": [
"ByteVec",
"U256",
"ByteVec",
"U256",
"ByteVec",
"ByteVec"
],
"isMutable": [
false,
false,
false,
false,
false,
false
]
},
Expand Down
6 changes: 3 additions & 3 deletions contracts/artifacts/TokenFurnace.ral.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": "v3.10.0",
"name": "TokenFurnace",
"bytecode": "04070912402d4040408440bf416c010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030305004025d30221c731b417031600cd42107b16010c33117b16000006170416024c081603d1a21604160116030005180516031604160116025673160316001601bd00030306011db1a000160016011406414c50480003130564130064170417031602d1a2a00040ce00160316040d1602c91705a0000d2aa100160502000001160140581401301401311401321401331401341401351401361401371401381401391401611401621401631401641401651401661710170f170e170d170c170b170a170917081707170617051704170317021701140017110c17121612160043314c402d1600161216120d2a626c1340ff3817131613103c130f3817141613130f381715161116147a1310314d0d2a784416157a1310314d0d2a7844171116120d2a17124a7fce161102",
"codeHash": "d0e8cba96b5dfdb2fd41df2553d98529bacd65e3ec91d424aea8e07292c2b3e3",
"bytecode": "0407408b409440af40c24106414741f401000000010c14403b646174613a6170706c69636174696f6e2f6a736f6e2c7b226e616d65223a2022546f6b656e204275726e65722050726f6f66202d2047726f757020b28c8944144036222c20226465736372697074696f6e223a202250726f766520796f757220746f6b656e73206275726e2e222c22696d616765223a202244ce01441402227d4402010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030305004025d30221c731b417031600cd42107b16010c33117b16000006170416024c081603d1a21604160116030005180516031604160116025673160316001601bd00030306014020b1a0001600160116024700061406414c50480003130664130064170417031602d1a2a00040ce00160316040d1602c91705a0000d2aa100160502000001160140581401301401311401321401331401341401351401361401371401381401391401611401621401631401641401651401661710170f170e170d170c170b170a170917081707170617051704170317021701140017110c17121612160043314c402d1600161216120d2a626c1340ff3817131613103c130f3817141613130f381715161116147a1310314d0d2a784416157a1310314d0d2a7844171116120d2a17124a7fce161102",
"codeHash": "b1fc1809498587ee52f79c339c41533972a701865f38a1e9e05ab1dcf31b64e2",
"fieldsSig": {
"names": [
"nftTemplateId",
"collectionUri",
"collectionImageUri",
"totalSupply",
"__stdInterfaceId"
],
Expand Down
3 changes: 2 additions & 1 deletion contracts/artifacts/ts/BurnerNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export namespace BurnerNFTTypes {
nftIndex: bigint;
tokenIdBurned: HexString;
amountBurned: bigint;
burnedBy: HexString;
};

export type State = ContractState<Fields>;
Expand Down Expand Up @@ -143,7 +144,7 @@ export const BurnerNFT = new Factory(
Contract.fromJson(
BurnerNFTContractJson,
"",
"de86ba673a50975a76b894d00590f4c907220136a3c32573024885245e6f5b75",
"80d0fff0dd5aba768a1fa0b2d16bad836f1eccef91704ede23970fea92a49a26",
[]
)
);
Expand Down
4 changes: 2 additions & 2 deletions contracts/artifacts/ts/TokenFurnace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { getContractByCodeHash, registerContract } from "./contracts";
export namespace TokenFurnaceTypes {
export type Fields = {
nftTemplateId: HexString;
collectionUri: HexString;
collectionImageUri: HexString;
totalSupply: bigint;
};

Expand Down Expand Up @@ -264,7 +264,7 @@ export const TokenFurnace = new Factory(
Contract.fromJson(
TokenFurnaceContractJson,
"",
"d0e8cba96b5dfdb2fd41df2553d98529bacd65e3ec91d424aea8e07292c2b3e3",
"b1fc1809498587ee52f79c339c41533972a701865f38a1e9e05ab1dcf31b64e2",
[]
)
);
Expand Down
5 changes: 3 additions & 2 deletions contracts/contracts/nftBurnerTemplate.ral
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ Contract BurnerNFT(
collectionId: ByteVec,
nftIndex: U256,
tokenIdBurned: ByteVec,
amountBurned: U256
amountBurned: U256,
burnedBy: ByteVec
) implements INFT {

pub fn getTokenUri() -> ByteVec {
//let _ = b`data:application/json,{"name": "Burn ` ++ u256ToString!(nftIndex) ++ b`", "attributes": [{"trait_type": "Token id", "value": "` ++ tokenIdBurned ++ b`"}, {"trait_type": "Amount burned", "value": "` ++ u256ToString!(amountBurned) ++ b`"}, {"trait_type": "Timestamp", "value": "`++ u256ToString!(blockTimeStamp!()) ++ b`"}]}`

return b`data:application/json,{"name": "Burn ` ++ u256ToString!(nftIndex) ++ b`", "attributes": [{"trait_type": "Amount burned", "value": ` ++ u256ToString!(amountBurned) ++ b`}, {"trait_type": "Timestamp", "value": `++ u256ToString!(blockTimeStamp!()) ++ b`}, {"trait_type": "Token Id", "value": "`++ tokenIdBurned ++ b`"}]}`
return b`data:application/json,{"name": "Burn ` ++ u256ToString!(nftIndex) ++ b`", "attributes": [{"trait_type": "Amount burned", "value": ` ++ u256ToString!(amountBurned) ++ b`}, {"trait_type": "Timestamp", "value": `++ u256ToString!(blockTimeStamp!()) ++ b`}, {"trait_type": "Token Id", "value": "`++ tokenIdBurned ++ b`"}, {"trait_type": "Burner", "value": "`++ burnedBy ++ b`"}]}`
}

pub fn getCollectionIndex() -> (ByteVec, U256) {
Expand Down
6 changes: 3 additions & 3 deletions contracts/contracts/token.ral
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "std/nft_collection_interface"
Contract TokenFurnace(
nftTemplateId: ByteVec,
collectionUri: ByteVec,
collectionImageUri: ByteVec,
mut totalSupply: U256
) implements INFTCollection {

Expand Down Expand Up @@ -34,7 +34,7 @@ Contract TokenFurnace(
@using(preapprovedAssets = true, updateFields = true)
fn mint(tokenIdBurned: ByteVec, amountBurned: U256, burnerCaller: Address) -> (ByteVec) {

let (initialImmState, initialMutState) = BurnerNFT.encodeFields!(selfContractId!(), totalSupply, tokenIdBurned, amountBurned)
let (initialImmState, initialMutState) = BurnerNFT.encodeFields!(selfContractId!(), totalSupply, tokenIdBurned, amountBurned, convert(toByteVec!(burnerCaller)))

let contractId = copyCreateSubContractWithToken!{burnerCaller -> ALPH: minimalContractDeposit!()}(
toByteVec!(totalSupply),
Expand All @@ -50,7 +50,7 @@ Contract TokenFurnace(
}

pub fn getCollectionUri() -> ByteVec {
return collectionUri
return b`data:application/json,{"name": "Token Burner Proof - Group `++ u256ToString!(groupOfAddress!(selfAddress!()))++ b`", "description": "Prove your tokens burn.","image": "` ++ collectionImageUri ++ b`"}`
}

pub fn totalSupply() -> U256 {
Expand Down
32 changes: 16 additions & 16 deletions contracts/deployments/.deployments.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
"deployerAddress": "1GBvuTs4TosNB9xTCGJL5wABn2xTYCzwa7MnXHphjcj1y",
"contracts": {
"BurnerNFT": {
"txId": "44028bc5dd483790f1df18161409d0e53ac8e33559ac216d6acf294e00e71374",
"unsignedTx": "000101010103000000081500e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef813c4016345785d8a0000a21440ec050240db40e6010000000115144025646174613a6170706c69636174696f6e2f6a736f6e2c7b226e616d65223a20224275726e20ce01894414403b222c202261747472696275746573223a205b7b2274726169745f74797065223a2022416d6f756e74206275726e6564222c202276616c7565223a2044ce0389441440287d2c207b2274726169745f74797065223a202254696d657374616d70222c202276616c7565223a20445689441440287d2c207b2274726169745f74797065223a2022546f6b656e204964222c202276616c7565223a202244ce02441404227d5d7d4402010000000203ce00ce010214110503000200030002000306414c50480003140100ad188000e0dbc1174876e800015b5eb0f9ca1326ca2d7b58f5d24f002afaea58b5bae42a1b523d8080bd098beaa6d52ce900023f97a5c7f8adbdd21c6a260a072228caf74062717aefa93390382ed89b5afebc01c50fd8c2ae76f790867c00e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef800000000000000000000",
"signature": "ec92323b68c8c2ae86c78c4d4a5b4be8c4390dfe4805244168caf6b775d22a756010dbbc27ba225b9e6775948db9c22a04ce8550e7f4b7c244f00cbaffc236b7",
"txId": "f9b487059d9e220b59b9558a0debd08404602c3a0adde7c2636aa9bafbdc90b0",
"unsignedTx": "000101010103000000081500e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef813c4016345785d8a0000a214411b0602410a4115010000000119144025646174613a6170706c69636174696f6e2f6a736f6e2c7b226e616d65223a20224275726e20ce01894414403b222c202261747472696275746573223a205b7b2274726169745f74797065223a2022416d6f756e74206275726e6564222c202276616c7565223a2044ce0389441440287d2c207b2274726169745f74797065223a202254696d657374616d70222c202276616c7565223a20445689441440287d2c207b2274726169745f74797065223a2022546f6b656e204964222c202276616c7565223a202244ce0244144028227d2c20207b2274726169745f74797065223a20224275726e6572222c202276616c7565223a202244ce04441404227d5d7d4402010000000203ce00ce010214403406030002000300020003402000000000000000000000000000000000000000000000000000000000000000000306414c50480003140100ad188000e17dc1174876e800015b5eb0f9ae0e8567cc994819873253a8a5c8ea8153779ad051f89173f11501c7daf778af00023f97a5c7f8adbdd21c6a260a072228caf74062717aefa93390382ed89b5afebc01c50ea8a45b01b07f567c00e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef800000000000000000000",
"signature": "03dd6637c0120bbc05e53b57723f73f5ea34878aa41af3d96813af8e0c01d05e41d222d81517c3168ce45c5504f192b3599f6f07a698cb2348cb232dde19abb7",
"gasPrice": "100000000000",
"gasAmount": 57563,
"blockHash": "000000612bfff5d74441cd349a77b30487bca30afc86c354d09e47e604765a30",
"codeHash": "7ea8d510165dfcc4438dc8f3f86ccc947cec8b1c9c0f02f4b852b88a6d28a8b0",
"gasAmount": 57725,
"blockHash": "0000000958807341136b3453825f71bd6465382e75e3db86014db15fdcae4830",
"codeHash": "a25dda4f67751bb754cfd9577cf3704842b57d51042d963d0656e8426e546d5d",
"contractInstance": {
"address": "215NpvAiVtqgVUHs9C966TzeSP9KoTNTBCi36kCVLXT8b",
"contractId": "5ee4d807eb96a93d0c48de2af5094b801024066cf5ba203a885f92ccd7d6db00",
"address": "27AaUAPcGXSDkxdLq8Em3pP5K8s3RB5MtZibrYi5PekoZ",
"contractId": "b9600886b2187e455cefe7697947b010801adb3200ddfa2909160879d14adc00",
"groupIndex": 0
}
},
"TokenFurnace": {
"txId": "2eb867e366e4aa9f0dbe6294c74c308d172cb12370dcc64aaaf513cde0d40de9",
"unsignedTx": "000101010103000000081500e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef813c4016345785d8a0000a214417a04070912402d4040408440bf416c010000000102ce0102010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030305004025d30221c731b417031600cd42107b16010c33117b16000006170416024c081603d1a21604160116030005180516031604160116025673160316001601bd00030306011db1a000160016011406414c50480003130564130064170417031602d1a2a00040ce00160316040d1602c91705a0000d2aa100160502000001160140581401301401311401321401331401341401351401361401371401381401391401611401621401631401641401651401661710170f170e170d170c170b170a170917081707170617051704170317021701140017110c17121612160043314c402d1600161216120d2a626c1340ff3817131613103c130f3817141613130f381715161116147a1310314d0d2a784416157a1310314d0d2a7844171116120d2a17124a7fce16110214406e030340205ee4d807eb96a93d0c48de2af5094b801024066cf5ba203a885f92ccd7d6db0003403f68747470733a2f2f617277656176652e6e65742f5a31484164545f50476e78504c6374342d75376c315a6c5f6834444e64787a4b6576377443444145666c630306414c504800021403010200ad188000e296c1174876e800015b5eb0f9958af5ad8f074c05bfac90708d0a5fa74bac28c495da11395f4a83fd9abb8e3800023f97a5c7f8adbdd21c6a260a072228caf74062717aefa93390382ed89b5afebc01c4082a8a83cc68300000e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef800000000000000000000",
"signature": "b43bd6bae57be1a09e15df0233f7f46a5be1aaee1f20a2eea56ffb583512e7a2685d7a91f1d6886d39bbd749ffdbb80be5d32b9a088906dce5a4ccae8c96e610",
"txId": "12b9e004fbf443d0be1f96ae182f3bf68359025eda989b4b4a9a0e4ed240b9b1",
"unsignedTx": "000101010103000000081500e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef813c4016345785d8a0000a21442040407408b409440af40c24106414741f401000000010c14403b646174613a6170706c69636174696f6e2f6a736f6e2c7b226e616d65223a2022546f6b656e204275726e65722050726f6f66202d2047726f757020b28c8944144036222c20226465736372697074696f6e223a202250726f766520796f757220746f6b656e73206275726e2e222c22696d616765223a202244ce01441402227d4402010000000102a0000201000102010f16000001310c7b160040cb17011601c50d7b16010201000203000816010002170216001602410e7b01030305004025d30221c731b417031600cd42107b16010c33117b16000006170416024c081603d1a21604160116030005180516031604160116025673160316001601bd00030306014020b1a0001600160116024700061406414c50480003130664130064170417031602d1a2a00040ce00160316040d1602c91705a0000d2aa100160502000001160140581401301401311401321401331401341401351401361401371401381401391401611401621401631401641401651401661710170f170e170d170c170b170a170917081707170617051704170317021701140017110c17121612160043314c402d1600161216120d2a626c1340ff3817131613103c130f3817141613130f381715161116147a1310314d0d2a784416157a1310314d0d2a7844171116120d2a17124a7fce16110214406e03034020b9600886b2187e455cefe7697947b010801adb3200ddfa2909160879d14adc0003403f68747470733a2f2f617277656176652e6e65742f686f784b3878433977526a445f3648694f7a686459326a57305a6e4a6f463266304e344663534c58717a510306414c504800021403010200ad188000e3aac1174876e800015b5eb0f965f4efe9ba80aa4c92aa01b67cdfe9f3e98ebc81756feccbe2c1b398a44a646500023f97a5c7f8adbdd21c6a260a072228caf74062717aefa93390382ed89b5afebc01c50ea72c60d1c447467c00e1ac0fe1e3a2d9f6f91da2045c7563ef3e43d9dc4fd244f9a41eae6bf0be6ef800000000000000000000",
"signature": "9e2ff44646f579b8d220fcdfccd704307f812af095688104d80c5a9c771cff275653f0da9c604115ccbd5b29a958f963f7c4d75b33eba4285f6167e940797d98",
"gasPrice": "100000000000",
"gasAmount": 58006,
"blockHash": "0000001483bdefb7e299f3c4d39a574e03e4cda6beb9a1d3287af1b09961a920",
"codeHash": "753176727625f8bbe925a9598be1902bf11797de4b4b6bd864aaddf864ccb0be",
"gasAmount": 58282,
"blockHash": "0000002562dab78bb38d09f5e82759cc34fe34af9638b7d8928c6fce56c8bac0",
"codeHash": "1d3e4c47e1c8e19855e3a062600df592e124f9f169002de6d2afc6c27a951372",
"contractInstance": {
"address": "23n9utpJY3uNC3py1tD23j5cTC7exyQYoNLXkgmfLTK5H",
"contractId": "870e6dc3cadf973670119697343f664f2b9b1e3b9328f042292fcfaa783c7b00",
"address": "26fBqJQn3XsD2J1wqo4ShH3eD1RMqtk55UsfQ5nMr3juq",
"contractId": "b1d89882ea690e8789b282ce1585b6bfa30c4e150feb3595d1edb6c61afdaf00",
"groupIndex": 0
}
}
Expand Down
9 changes: 5 additions & 4 deletions contracts/scripts/0_deploy_faucet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Deployer, DeployFunction, Network } from '@alephium/cli'
import { Settings } from '../alephium.config'
import { TokenFurnace, BurnerNFT } from '../artifacts/ts'
import { hexToString, stringToHex } from '@alephium/web3'
import { hexToString, NULL_CONTRACT_ADDRESS, stringToHex } from '@alephium/web3'
import { expectAssertionError, mintToken } from '@alephium/web3-test'

// This deploy function will be called by cli deployment tool automatically
Expand All @@ -20,7 +20,8 @@ const deployFaucet: DeployFunction<Settings> = async (
collectionId: '',
nftIndex: 0n,
tokenIdBurned: '',
amountBurned: 0n
amountBurned: 0n,
burnedBy: NULL_CONTRACT_ADDRESS
}
})

Expand All @@ -33,8 +34,8 @@ const deployFaucet: DeployFunction<Settings> = async (
// The initial states of the faucet contract
initialFields: {
nftTemplateId: nftTemplateResult.contractInstance.contractId,
collectionUri: stringToHex("https://arweave.net/Z1HAdT_PGnxPLct4-u7l1Zl_h4DNdxzKev7tCDAEflc"),
totalSupply: 0n
totalSupply: 0n,
collectionImageUri: stringToHex('https://arweave.net/hoxK8xC9wRjD_6HiOzhdY2jW0ZnJoF2f0N4FcSLXqzQ')
}
})

Expand Down

0 comments on commit 69a847b

Please sign in to comment.