diff --git a/scripts/src/ec_stark.ts b/scripts/src/ec_stark.ts index f71ed31..38b0d57 100644 --- a/scripts/src/ec_stark.ts +++ b/scripts/src/ec_stark.ts @@ -1,8 +1,11 @@ import * as starkCurve from 'micro-starknet'; import { merkle, num,cairo, encode } from 'starknet'; -// array of [address, token_id, task_id, name, rank, score, level, total_eligible_users] +// notice: list is array of [address, token_id, task_id, name, rank, score, level, total_eligible_users] +// For example: let list = [['0x35742331cbd91fc4873c469ba52939db909efcf46b9c28e82d1baaa7078a6d6', 10,1,'L1PW',10,406872312314,0,76769]]; + +// notice: change the private_key to your own private_key const private_key = '0x019800ea6a9a73f94aee6a3d2edf018fc770443e90c7ba121e8303ec6b349279'; const pubKey = starkCurve.getStarkKey(private_key); diff --git a/scripts/src/example/example.txt b/scripts/src/example/example.txt new file mode 100644 index 0000000..ecccb73 --- /dev/null +++ b/scripts/src/example/example.txt @@ -0,0 +1,10 @@ +0x7a447b701a09c8f8baad6c163bb279207fa406ef5d574709f99ed4bcee84872,1,1,L1PW,1,1836905163976,0,76769,[0x7d7a829fb4268dc93bb7d1f719205b871fbff4ffdd6ddcf41b5736d6e8272ea, 0x38e91a4bed95c621bc607ead055b73e49a58ffc37399f31a0a663cef294cc2, 0x64f35f8e3ede17d57f688f9465388a06882c2666a62d0e6fde6466d8effd1c0, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x26eaf74eec0a32ee3640984649756899a15df4bb1e35e150324e45e8178813,2,1,L1PW,2,1451909069479,0,76769,[0x7df41eca698f38f7b4a71d4295499e6ee89eadeb8e07a064bb80433894c397e, 0x38e91a4bed95c621bc607ead055b73e49a58ffc37399f31a0a663cef294cc2, 0x64f35f8e3ede17d57f688f9465388a06882c2666a62d0e6fde6466d8effd1c0, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x5b39f7aa0e017870b4d639c294411f8908237bcfcaabfaa5b007e28a20535c0,3,1,L1PW,3,1450090271481,0,76769,[0x586ce278f072bc7f203ec5e8185087011d9de13fe5c6ff9ee3e384840b2bb73, 0x7e9f6a7efc107fcdbf7265b59ae034de78daf59694d46d7aee3f19651626a7d, 0x64f35f8e3ede17d57f688f9465388a06882c2666a62d0e6fde6466d8effd1c0, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x17149fc72fd3058583f564e049d069e93412ea00c7823bbf58475404819ea63,4,1,L1PW,4,896438614568,0,76769,[0x95f855bdf3826b5637877fa45f62ab79853fe90a5cdbc5fdd65014748f118e, 0x7e9f6a7efc107fcdbf7265b59ae034de78daf59694d46d7aee3f19651626a7d, 0x64f35f8e3ede17d57f688f9465388a06882c2666a62d0e6fde6466d8effd1c0, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x284a1ad6382cffc520d8f711cf9519ccf43b3c105b89ef081cbe1a625322410,5,1,L1PW,5,889181496710,0,76769,[0x6ac116df992fa7cd4e3a42273a31a2bca4d7f1dc8b36fd1f1a587c0fec79195, 0x2e1accd7b51eeba2615298c132f24e2cd41255f5b1cce2de9bd5610f326b6a7, 0x3a67e08dd2d36fd51ac90961163d3624c9ae6c3714af0576c19771cd96d105c, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x142ebfb10673013a9d75f86aceafd5ecc4df6e78d3776e57a280a240bf9ccaf,6,1,L1PW,6,735508058239,0,76769,[0x7ac57b31a104fc10728d70f8b8fc4f7c9144079be087e019292ee88e8659777, 0x2e1accd7b51eeba2615298c132f24e2cd41255f5b1cce2de9bd5610f326b6a7, 0x3a67e08dd2d36fd51ac90961163d3624c9ae6c3714af0576c19771cd96d105c, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x8b5dbd611f1c2d9f6e054982a6ef9425e0827436d030bed096843e7836a0a3,7,1,L1PW,7,477227796407,0,76769,[0x95ba938c79288ddad9af8609d3f48fa9e7929260f3ba9d739a77ccfacf5067, 0x766590f7a4abbeef58145c34f8aa049de95faeb12e7a2ec4ad942624eb08a41, 0x3a67e08dd2d36fd51ac90961163d3624c9ae6c3714af0576c19771cd96d105c, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x1b3c9ba30910ba7a653cb08754d30e58847380b4ff886ab7938aa512948e11c,8,1,L1PW,8,464052115221,0,76769,[0x3effe1f9a1fca51720002e98b639f406332b9ab733226bbf117ba0d32c703b1, 0x766590f7a4abbeef58145c34f8aa049de95faeb12e7a2ec4ad942624eb08a41, 0x3a67e08dd2d36fd51ac90961163d3624c9ae6c3714af0576c19771cd96d105c, 0x128fc6f45cf8b71f357713f6e36c5043325e95e4927b8d6db312af80a72321c, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x67558ae622270074d2109b68aaa53d72a5e0330344676bd899ba84fa69bcc6,9,1,L1PW,9,431619633131,0,76769,[0x5180c14347d4bfcc7a746a4e82016b7b2f243f86365dc3355ec40e6814d4f41, 0xb0e5a3fb482c4fa849ccf1b5df658765fc4d7c5098fe3d8a2b43d0f1af6edd, 0x923dca6d5438f31c9e1cc1b2cd08a5aebf79842a382cabb76ae4ed832d97be, 0x4081183b5464d63894bbd8769e6ffef977fe9669469d0e2a0e6b4d2d8298f36, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] +0x35742331cbd91fc4873c469ba52939db909efcf46b9c28e82d1baaa7078a6d6,10,1,L1PW,10,406872312314,0,76769,[0x66e7169b0731c8eb021cf5e09a803d62a66cc01cdb42bedfbea9de90858b9e4, 0xb0e5a3fb482c4fa849ccf1b5df658765fc4d7c5098fe3d8a2b43d0f1af6edd, 0x923dca6d5438f31c9e1cc1b2cd08a5aebf79842a382cabb76ae4ed832d97be, 0x4081183b5464d63894bbd8769e6ffef977fe9669469d0e2a0e6b4d2d8298f36, 0x6cdf09187175a80b6cc4ad8dad44af7d65d5b22f51d3dd742a9bf2ce85d455b, 0x5b6eba0c456c58833fcb4be518d20dc6e2dc29079e2b61a5b1e10cbf9e46bfc, 0x25c2ab011f0339dfa5c810b6cd6daff0ccd78afc88758da6af890db7dd2f0aa, 0x7ff636821e88f5f9943a306579f7c5ea202402155ad89d9e8fc542eab34619f, 0x45c13f5d5211898c9bd9b5560a4d76a6ce7c36804e2eac3f8baa1197e7b12e7, 0xb37a422d6d1694a629eaf08ec7d81ee2c009655cae64000bf1ccf8261422f0, 0x4c5a9d1aeb7a93407504beec91e7256bbb8fa071bac32bc69bce019d471483e, 0x36bae232461bfecb202be7906fe406b7baaeae4ca4150cbb38d7c7a8adc2070, 0x30a1705efb2527295d44157202795133ba729dfb3e16ce9a63b0ecf90433e0b, 0x124bcbc7f61601e434e5fc5181982f9cc9441d77f9da68ac3bd5a17ecf0ce26, 0x4243240599db68c30370219713a8f9b0f3c978856082a0c6f20aa945ff9cf, 0x5561116dfd3500403473bcff6d291debdcc45b72ad44c4491a1e1b75b8c4e7f, 0x7b4427387cb6c04cdcb0f348186bd35ee678cd4b20598e66ecb73a5e906e1a5] \ No newline at end of file diff --git a/scripts/src/generate_merkle_json.ts b/scripts/src/generate_merkle_json.ts index e9c2fff..d1bb5ae 100644 --- a/scripts/src/generate_merkle_json.ts +++ b/scripts/src/generate_merkle_json.ts @@ -2,18 +2,14 @@ import { merkle, num,cairo } from 'starknet'; import * as starkCurve from 'micro-starknet'; import * as fs from 'fs'; -// read data from .csv file -// array of [address, token_id, task_id, name, rank, score, level, total_eligible_users] - -// let list = [['0x0138EfE7c064c69140e715f58d1e29FC75E5594D342E568246a4D6a3131a5974', 1, 1, parseInt(cairo.felt('L1P1')), 10, 12000, 6, 120000], -// ['0x02b9cE3e6869192006820c2B41c084BAB97f17DAe966b981dCA2FDae1C178065', 2, 1, parseInt(cairo.felt('L1P2')), 20, 11000, 6, 120000], -// ['0x0161A9bCA8dCc5975A03b12f5F7bF9610e1541635eb40eB3A89bAeeDC168e636', 3, 1, parseInt(cairo.felt('L1P1')), 320, 10000, 6, 120000], -// ['0x044F7CbDa8f82641C1F7D1b1a6BC56956d71acb4E0B51eEE742545b6aa08D0a0', 4, 1, parseInt(cairo.felt('L1P1')), 420, 9000, 6, 120000], -// ['0x0044B02486f7ED5D586b846094eD727b08E72B8C2eFa738293f3Ef864966514C', 5, 1, parseInt(cairo.felt('L1P1')), 520, 8000, 6, 120000], -// ['0x0138EfE7c064c69140e715f58d1e29FC75E5594D342E568246a4D6a3131a597E', 6, 1, parseInt(cairo.felt('L1P1')), 620, 7000, 6, 120000], -// ]; type Data = [string, number, number, number, number, number, number, number, string[]]; -let list = fs.readFileSync('/home/felix/Downloads/median/output10_proof.txt', 'utf8').split('\n').map(line => { + +// notice: change the root to your own root +let root = "0x364416474922e527188122afdfa40a0eb0ed046369ce6a2365dac91113fbee0"; +// read list from file, +// file format: address, token_id, task_id, name, rank, score, level, total_eligible_users, proof +// notice: replace the file path to your own file path +let list = fs.readFileSync('./example/example.txt', 'utf8').split('\n').map(line => { if (line === '') { return null; } @@ -27,44 +23,6 @@ let list = fs.readFileSync('/home/felix/Downloads/median/output10_proof.txt', 'u let data: Data = [splitLine[0], parseInt(splitLine[1]), parseInt(splitLine[2]), parseInt(cairo.felt(splitLine[3])), parseInt(splitLine[4]), parseInt(splitLine[5]), parseInt(splitLine[6]), parseInt(splitLine[7]), proofArray]; return data; }); -// remove the last item if it's an empty string -// if (list[list.length - 1].length === 1 && list[list.length - 1][0] === '') { -// list.pop(); -// } - -let root = "0x364416474922e527188122afdfa40a0eb0ed046369ce6a2365dac91113fbee0"; - - -// convert to aim list, each item is hash of two elements -// let aimList = list.map(item => { -// let tmp = starkCurve.pedersen(BigInt(item[0]), BigInt(item[1])) -// tmp = starkCurve.pedersen(BigInt(tmp), BigInt(item[2])) -// tmp = starkCurve.pedersen(BigInt(tmp), BigInt(item[3])) -// tmp = starkCurve.pedersen(BigInt(tmp), BigInt(item[4])) -// tmp = starkCurve.pedersen(BigInt(tmp), BigInt(item[5])) -// tmp = starkCurve.pedersen(BigInt(tmp), BigInt(item[6])) -// tmp = starkCurve.pedersen(BigInt(tmp), BigInt(item[7])) - -// return tmp; -// }) -// const tree = new merkle.MerkleTree(aimList); - -// let i = 1; -// console.log("root = " + tree.root); - -// for (let i of [1,2,3,4]) { - -// console.log("address = " + list[i][0]) - - -// console.log("token_id = " + list[i][1]); - -// console.log("proof = " + tree.getProof(aimList[i])) - - -// console.log("token_metadata is " + list[i][2] + "," + cairo.felt(list[i][3]) + "," + list[i][4] + "," + list[i][5] + "," + list[i][6] + "," + list[i][7]) -// console.log("-----------------------------------------") -// } // store each address to a map based on their last address digit let map = new Map(); diff --git a/scripts/src/generate_metadata_json.ts b/scripts/src/generate_metadata_json.ts index 390203c..9c52390 100644 --- a/scripts/src/generate_metadata_json.ts +++ b/scripts/src/generate_metadata_json.ts @@ -2,10 +2,20 @@ import { merkle, num,cairo } from 'starknet'; import * as starkCurve from 'micro-starknet'; import * as fs from 'fs'; -// read data from .csv file -// array of [address, token_id, task_id, name, rank, score, level, total_eligible_users, proof] type Data = [string, number, number, string, number, number, number, number, string[]]; -let list = fs.readFileSync('/home/felix/Downloads/median/output10_proof.txt', 'utf8').split('\n').map(line => { + + +// some prefix and suffix: change to your own config +let dir_prefix = '/home/felix/Downloads/median/ipfs-json/'; +let cid_prefix = 'https://static.missions.jediswap.xyz/static-nft/high-definition/'; +let cid_suffix = '.png'; +let anmation_url_prefix = 'https://static.missions.jediswap.xyz/3d-animated-nft/'; +let animation_url_suffix = '.mp4'; + +// read list from file, +// file format: address, token_id, task_id, name, rank, score, level, total_eligible_users, proof +// notice: replace the file path to your own file path +let list = fs.readFileSync('./example/example.txt', 'utf8').split('\n').map(line => { if (line === '') { return null; } @@ -20,13 +30,6 @@ let list = fs.readFileSync('/home/felix/Downloads/median/output10_proof.txt', 'u return data; }); -let dir_prefix = '/home/felix/Downloads/median/ipfs-json/'; - -let cid_prefix = 'https://static.missions.jediswap.xyz/static-nft/high-definition/'; -let cid_suffix = '.png'; - -let anmation_url_prefix = 'https://static.missions.jediswap.xyz/3d-animated-nft/'; -let animation_url_suffix = '.mp4'; // make dir if not exist if (!fs.existsSync(dir_prefix)) { @@ -65,18 +68,4 @@ for (let i = 0; i < list.length; i++) { ] }; fs.writeFileSync(dir_prefix + fileName + '.json', JSON.stringify(data)); -} - -// // write to file for each map item, and file name is the last digit -// for (let [key, value] of map) { -// let fileName = key + ".json"; -// let data = { -// root: root, -// data: value -// }; -// fs.writeFile(fileName, JSON.stringify(data), function (err) { -// if (err) { -// return console.error(err); -// } -// }); -// } \ No newline at end of file +} \ No newline at end of file diff --git a/scripts/src/merkle_stark.ts b/scripts/src/merkle_stark.ts index 1354e59..6a4d660 100644 --- a/scripts/src/merkle_stark.ts +++ b/scripts/src/merkle_stark.ts @@ -1,9 +1,8 @@ import { merkle, num,cairo } from 'starknet'; import * as starkCurve from 'micro-starknet'; -import * as fs from 'fs'; -// read data from .csv file -// array of [address, token_id, task_id, name, rank, score, level, total_eligible_users] +// notice: list is array of [address, token_id, task_id, name, rank, score, level, total_eligible_users] +// For example: let list = [['0x0138EfE7c064c69140e715f58d1e29FC75E5594D342E568246a4D6a3131a5974', 1, 1, 'L1P1', 10, 12000, 6, 120000], ['0x02b9cE3e6869192006820c2B41c084BAB97f17DAe966b981dCA2FDae1C178065', 2, 1, 'L1P2', 20, 11000, 6, 120000], ['0x0179B1211Aed20097bBbA0369088db3D30eCe0550015C08Ea7E521BBa99e76D2', 3, 1, 'L1P1', 320, 10000, 6, 120000],