From d643656831ca71d694c8326fc43a2d1f5c1a204f Mon Sep 17 00:00:00 2001 From: hide-on-bush-x Date: Fri, 5 May 2023 12:56:17 -0300 Subject: [PATCH] ASBT Stuff --- src/helpers/ASBT.ts | 603 +++++++++++++++++++++++++++++++++++++++ stories/masa.stories.tsx | 75 ++++- 2 files changed, 676 insertions(+), 2 deletions(-) create mode 100644 src/helpers/ASBT.ts diff --git a/src/helpers/ASBT.ts b/src/helpers/ASBT.ts new file mode 100644 index 00000000..f8a99334 --- /dev/null +++ b/src/helpers/ASBT.ts @@ -0,0 +1,603 @@ +export const abi = [ + { + inputs: [ + { + internalType: "address", + name: "admin", + type: "address", + }, + { + internalType: "string", + name: "name", + type: "string", + }, + { + internalType: "string", + name: "symbol", + type: "string", + }, + { + internalType: "string", + name: "baseTokenURI", + type: "string", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "SameValue", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "_owner", + type: "address", + }, + { + indexed: true, + internalType: "uint256", + name: "_tokenId", + type: "uint256", + }, + ], + name: "Burn", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "_owner", + type: "address", + }, + { + indexed: true, + internalType: "uint256", + name: "_tokenId", + type: "uint256", + }, + ], + name: "Mint", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "to", + type: "address", + }, + ], + name: "Minted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "previousAdminRole", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "newAdminRole", + type: "bytes32", + }, + ], + name: "RoleAdminChanged", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleGranted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleRevoked", + type: "event", + }, + { + inputs: [], + name: "DEFAULT_ADMIN_ROLE", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "MINTER_ROLE", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "addLinkPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "addLinkPriceMASA", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "burn", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "exists", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + ], + name: "getRoleAdmin", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "grantRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "hasRole", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address", + }, + ], + name: "mint", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "ownerOf", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "queryLinkPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "queryLinkPriceMASA", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "renounceRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "role", + type: "bytes32", + }, + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "revokeRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_addLinkPrice", + type: "uint256", + }, + ], + name: "setAddLinkPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_addLinkPriceMASA", + type: "uint256", + }, + ], + name: "setAddLinkPriceMASA", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_queryLinkPrice", + type: "uint256", + }, + ], + name: "setQueryLinkPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "_queryLinkPriceMASA", + type: "uint256", + }, + ], + name: "setQueryLinkPriceMASA", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "interfaceId", + type: "bytes4", + }, + ], + name: "supportsInterface", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "tokenByIndex", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "uint256", + name: "index", + type: "uint256", + }, + ], + name: "tokenOfOwnerByIndex", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "tokenURI", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, +]; +export const bytecode: string = + "0x60806040523480156200001157600080fd5b5060405162001c5b38038062001c5b8339810160408190526200003491620002bc565b8383838383838383828281600090805190602001906200005692919062000190565b5080516200006c90600190602084019062000190565b506200007e91506000905085620000d8565b80516200009390600990602084019062000190565b5050505050620000ca7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a685620000d860201b60201c565b5050505050505050620004c5565b620000e4828262000163565b6200015f5760008281526008602090815260408083206001600160a01b03851684529091529020805460ff191660011790556200011e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff165b92915050565b8280546200019e9062000412565b90600052602060002090601f016020900481019282620001c257600085556200020d565b82601f10620001dd57805160ff19168380011785556200020d565b828001600101855582156200020d579182015b828111156200020d578251825591602001919060010190620001f0565b506200021b9291506200021f565b5090565b5b808211156200021b576000815560010162000220565b60006200024d62000247846200039d565b6200037e565b9050828152602081018484840111156200026a576200026a600080fd5b62000277848285620003df565b509392505050565b80516200018a81620004ab565b600082601f830112620002a257620002a2600080fd5b8151620002b484826020860162000236565b949350505050565b60008060008060808587031215620002d757620002d7600080fd5b6000620002e587876200027f565b94505060208501516001600160401b03811115620003065762000306600080fd5b62000314878288016200028c565b93505060408501516001600160401b03811115620003355762000335600080fd5b62000343878288016200028c565b92505060608501516001600160401b03811115620003645762000364600080fd5b62000372878288016200028c565b91505092959194509250565b60006200038a60405190565b905062000398828262000443565b919050565b60006001600160401b03821115620003b957620003b96200048b565b620003c482620004a1565b60200192915050565b60006001600160a01b0382166200018a565b60005b83811015620003fc578181015183820152602001620003e2565b838111156200040c576000848401525b50505050565b6002810460018216806200042757607f821691505b602082108114156200043d576200043d62000475565b50919050565b6200044e82620004a1565b81018181106001600160401b03821117156200046e576200046e6200048b565b6040525050565b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b601f01601f191690565b620004b681620003cd565b8114620004c257600080fd5b50565b61178680620004d56000396000f3fe608060405234801561001057600080fd5b50600436106101495760003560e01c806301ffc9a71461014e57806306fdde031461017757806313150b481461018c57806318160ddd146101a25780631f37c124146101aa578063248a9ca3146101b3578063289c686b146101c65780632f2ff15d146101db5780632f745c59146101ee57806336568abe146102015780633c72ae701461021457806342966c68146102275780634f558e791461023a5780634f6ccce71461024d5780636352211e146102605780636a6278421461028057806370a0823114610293578063776d1a54146102a65780637db8cb68146102af57806391d14854146102c257806395d89b41146102d5578063a217fddf146102dd578063b97d6b23146102e5578063c87b56dd146102ee578063d539139314610301578063d547741f14610316578063fd48ac8314610329575b600080fd5b61016161015c3660046111bd565b61033c565b60405161016e91906114f3565b60405180910390f35b61017f61034d565b60405161016e919061150f565b610195600d5481565b60405161016e9190611501565b600654610195565b610195600a5481565b6101956101c1366004611169565b6103df565b6101d96101d4366004611169565b6103f4565b005b6101d96101e936600461118a565b610428565b6101956101fc36600461112c565b610449565b6101d961020f36600461118a565b6104a4565b6101d9610222366004611169565b6104da565b6101d9610235366004611169565b61050e565b610161610248366004611169565b610540565b61019561025b366004611169565b61054b565b61027361026e366004611169565b610599565b60405161016e91906114e5565b61019561028e366004611103565b6105ce565b6101956102a1366004611103565b61061b565b610195600b5481565b6101d96102bd366004611169565b61065f565b6101616102d036600461118a565b610693565b61017f6106be565b610195600081565b610195600c5481565b61017f6102fc366004611169565b6106cd565b61019560008051602061173183398151915281565b6101d961032436600461118a565b610734565b6101d9610337366004611169565b610750565b600061034782610784565b92915050565b60606000805461035c90611671565b80601f016020809104026020016040519081016040528092919081815260200182805461038890611671565b80156103d55780601f106103aa576101008083540402835291602001916103d5565b820191906000526020600020905b8154815290600101906020018083116103b857829003601f168201915b5050505050905090565b60009081526008602052604090206001015490565b60006103ff816107a9565b81600a5414156104225760405163c23f6ccb60e01b815260040160405180910390fd5b50600a55565b610431826103df565b61043a816107a9565b61044483836107b3565b505050565b60006104548361061b565b821061047b5760405162461bcd60e51b815260040161047290611540565b60405180910390fd5b506001600160a01b03919091166000908152600460209081526040808320938352929052205490565b6001600160a01b03811633146104cc5760405162461bcd60e51b8152600401610472906115a0565b6104d68282610839565b5050565b60006104e5816107a9565b81600b5414156105085760405163c23f6ccb60e01b815260040160405180910390fd5b50600b55565b61051833826108a0565b6105345760405162461bcd60e51b815260040161047290611560565b61053d816108c3565b50565b60006103478261095d565b600061055660065490565b82106105745760405162461bcd60e51b815260040161047290611590565b60068281548110610587576105876116da565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806103475760405162461bcd60e51b815260040161047290611580565b6000806105da8361097a565b90507fb9203d657e9c0ec8274c818292ab0f58b04e1970050716891770eb1bab5d655e818460405161060d9291906115b0565b60405180910390a192915050565b60006001600160a01b0382166106435760405162461bcd60e51b815260040161047290611550565b506001600160a01b031660009081526003602052604090205490565b600061066a816107a9565b81600d54141561068d5760405163c23f6ccb60e01b815260040160405180910390fd5b50600d55565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606001805461035c90611671565b60606106d8826109c2565b60006106e26109e7565b90506000815111610702576040518060200160405280600081525061072d565b8061070c846109f6565b60405160200161071d929190611465565b6040516020818303038152906040525b9392505050565b61073d826103df565b610746816107a9565b6104448383610839565b600061075b816107a9565b81600c54141561077e5760405163c23f6ccb60e01b815260040160405180910390fd5b50600c55565b60006001600160e01b03198216637965db0b60e01b1480610347575061034782610a92565b61053d8133610ab7565b6107bd8282610693565b6104d65760008281526008602090815260408083206001600160a01b03851684529091529020805460ff191660011790556107f53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6108438282610693565b156104d65760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000806108ac83610599565b6001600160a01b0385811691161491505092915050565b60006108ce82610599565b90506108dc81600084610b10565b6001600160a01b0381166000908152600360205260408120805460019290610905908490611602565b909155505060008281526002602052604080822080546001600160a01b03191690555183916001600160a01b038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59190a35050565b6000908152600260205260409020546001600160a01b0316151590565b6000600080516020611731833981519152610994816107a9565b600061099f600e5490565b90506109af600e80546001019055565b6109b98482610b1b565b91505b50919050565b6109cb8161095d565b61053d5760405162461bcd60e51b815260040161047290611580565b60606009805461035c90611671565b60606000610a0383610bf7565b60010190506000816001600160401b03811115610a2257610a226116f0565b6040519080825280601f01601f191660200182016040528015610a4c576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084610a8557610a8a565b610a56565b509392505050565b60006001600160e01b0319821663780e9d6360e01b1480610347575061034782610ccd565b610ac18282610693565b6104d657610ace81610d1d565b610ad9836020610d2f565b604051602001610aea929190611493565b60408051601f198184030181529082905262461bcd60e51b82526104729160040161150f565b610444838383610e9a565b6001600160a01b038216610b415760405162461bcd60e51b815260040161047290611530565b610b4a8161095d565b15610b675760405162461bcd60e51b815260040161047290611570565b610b7360008383610b10565b6001600160a01b0382166000908152600360205260408120805460019290610b9c9084906115cb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b038616908117909155905183927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688591a35050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610c365772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6904ee2d6d415b85acef8160201b8310610c60576904ee2d6d415b85acef8160201b830492506020015b662386f26fc100008310610c7e57662386f26fc10000830492506010015b6305f5e1008310610c96576305f5e100830492506008015b6127108310610caa57612710830492506004015b60648310610cbc576064830492506002015b600a83106103475760010192915050565b60006001600160e01b031982166313f2a32f60e01b1480610cfe57506001600160e01b03198216635b5e139f60e01b145b8061034757506301ffc9a760e01b6001600160e01b0319831614610347565b60606103476001600160a01b03831660145b60606000610d3e8360026115e3565b610d499060026115cb565b6001600160401b03811115610d6057610d606116f0565b6040519080825280601f01601f191660200182016040528015610d8a576020820181803683370190505b509050600360fc1b81600081518110610da557610da56116da565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110610dd457610dd46116da565b60200101906001600160f81b031916908160001a9053506000610df88460026115e3565b610e039060016115cb565b90505b6001811115610e7b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610e3757610e376116da565b1a60f81b828281518110610e4d57610e4d6116da565b60200101906001600160f81b031916908160001a90535060049490941c93610e748161165a565b9050610e06565b50831561072d5760405162461bcd60e51b815260040161047290611520565b6001600160a01b038316610ef557610ef081600680546000838152600760205260408120829055600182018355919091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0155565b610f18565b816001600160a01b0316836001600160a01b031614610f1857610f188382610f52565b6001600160a01b038216610f2f5761044481610fef565b826001600160a01b0316826001600160a01b03161461044457610444828261109e565b60006001610f5f8461061b565b610f699190611602565b600083815260056020526040902054909150808214610fbc576001600160a01b03841660009081526004602090815260408083208584528252808320548484528184208190558352600590915290208190555b5060009182526005602090815260408084208490556001600160a01b039094168352600481528383209183525290812055565b60065460009061100190600190611602565b60008381526007602052604081205460068054939450909284908110611029576110296116da565b90600052602060002001549050806006838154811061104a5761104a6116da565b6000918252602080832090910192909255828152600790915260408082208490558582528120556006805480611082576110826116c4565b6001900381819060005260206000200160009055905550505050565b60006110a98361061b565b6001600160a01b039093166000908152600460209081526040808320868452825280832085905593825260059052919091209190915550565b803561034781611706565b80356103478161171a565b803561034781611720565b60006020828403121561111857611118600080fd5b600061112484846110e2565b949350505050565b6000806040838503121561114257611142600080fd5b600061114e85856110e2565b925050602061115f858286016110ed565b9150509250929050565b60006020828403121561117e5761117e600080fd5b600061112484846110ed565b600080604083850312156111a0576111a0600080fd5b60006111ac85856110ed565b925050602061115f858286016110e2565b6000602082840312156111d2576111d2600080fd5b600061112484846110f8565b6111e781611619565b82525050565b8015156111e7565b806111e7565b6000611205825190565b80845260208401935061121c81856020860161162a565b601f01601f19169290920192915050565b6000611237825190565b61124581856020860161162a565b9290920192915050565b60208082527f537472696e67733a20686578206c656e67746820696e73756666696369656e74910190815260005b5060200190565b601d81526000602082017f5342543a206d696e7420746f20746865207a65726f20616464726573730000008152915061127d565b602881526000602082017f534254456e756d657261626c653a206f776e657220696e646578206f7574206f8152676620626f756e647360c01b602082015291505b5060400190565b602681526000602082017f5342543a2061646472657373207a65726f206973206e6f7420612076616c69648152651037bbb732b960d11b602082015291506112f9565b601e81526000602082017f5342543a2063616c6c6572206973206e6f7420746f6b656e206f776e657200008152915061127d565b601981526000602082017814d0950e881d1bdad95b88185b1c9958591e481b5a5b9d1959603a1b8152915061127d565b601581526000602082017414d0950e881a5b9d985b1a59081d1bdad95b881251605a1b8152915061127d565b602981526000602082017f534254456e756d657261626c653a20676c6f62616c20696e646578206f7574208152686f6620626f756e647360b81b602082015291506112f9565b602f81526000602082017f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636581526e103937b632b9903337b91039b2b63360891b602082015291506112f9565b6000611471828561122d565b915061147d828461122d565b64173539b7b760d91b8152915060058201611124565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260170160006114bf828561122d565b7001034b99036b4b9b9b4b733903937b6329607d1b81526011019150611124828461122d565b6020810161034782846111de565b6020810161034782846111ed565b6020810161034782846111f5565b6020808252810161072d81846111fb565b602080825281016103478161124f565b6020808252810161034781611284565b60208082528101610347816112b8565b6020808252810161034781611300565b6020808252810161034781611343565b6020808252810161034781611377565b60208082528101610347816113a7565b60208082528101610347816113d3565b6020808252810161034781611419565b604081016115be82856111f5565b61072d60208301846111de565b600082198211156115de576115de611698565b500190565b60008160001904831182151516156115fd576115fd611698565b500290565b60008282101561161457611614611698565b500390565b60006001600160a01b038216610347565b60005b8381101561164557818101518382015260200161162d565b83811115611654576000848401525b50505050565b60008161166957611669611698565b506000190190565b60028104600182168061168557607f821691505b602082108114156109bc576109bc6116ae565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b61170f81611619565b811461053d57600080fd5b8061170f565b6001600160e01b0319811661170f56fe9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6a26469706673582212208a36f8f29cfa75dcbd2512a983fca56a39397b3e8f0156cad654a16df50a803664736f6c63430008070033"; diff --git a/stories/masa.stories.tsx b/stories/masa.stories.tsx index b5510dab..026332de 100644 --- a/stories/masa.stories.tsx +++ b/stories/masa.stories.tsx @@ -4,6 +4,10 @@ import React, { useCallback } from 'react'; import { MasaProvider, ModalComponent, queryClient, useMasa } from '../src'; import { Args, Meta, Story } from '@storybook/react'; import InterfaceMasaGreen from '../src/components/masa-interface/pages/masa-green'; +import { Masa, Messages, loadSBTContract } from '@masa-finance/masa-sdk'; +import { Contract } from 'ethers'; +import { abi } from '../src/helpers/ASBT'; + const meta: Meta = { title: 'SDK Test', component: () => <>, @@ -34,8 +38,72 @@ const Component = (): JSX.Element => { openChainModal, openGallery, + masa, } = useMasa(); + const mintBadge = async () => { + if (masa && masa.config) { + const sbtContract = await loadSBTContract( + masa?.config, + '0x120AEBA02b9e125b8C148F466B6417Bb88Cf3bDE' + ); + + console.log({ sbtContract }); + if (sbtContract) + mintASBT( + masa, + sbtContract, + '0x988055AA2038Fc8aB06E90CBB3E6BF5aEBe7b5Dc' + ); + } + }; + + const mintASBT = async (masa: Masa, sbtContract: any, receiver: string) => { + const [name, symbol] = await Promise.all([ + sbtContract.name(), + sbtContract.symbol(), + ]); + + console.log('Minting SBT on:'); + console.log(`Contract Name: '${name}'`); + console.log(`Contract Symbol: '${symbol}'`); + console.log(`Contract Address: '${sbtContract.address}'`); + console.log(`To receiver: '${receiver}'`); + + const asbt = await new Contract( + sbtContract.address, + abi, + masa.config.wallet + ).deployed(); + + const { wait, hash } = await asbt.mint(receiver); + console.log(Messages.WaitingToFinalize(hash)); + + const { logs } = await wait(); + + const parsedLogs = masa.contracts.parseLogs(logs, [asbt]); + + const mintEvent = parsedLogs.find((log: any) => log.name === 'Mint'); + + if (mintEvent) { + const { args } = mintEvent; + console.log( + `Minted to token with ID: ${args._tokenId} receiver '${args._owner}'` + ); + } + }; + + const deployASBT = async () => { + const address = await masa?.sbt.deployASBT( + 'Masa Ambassador', + 'AMASADOR', + 'https://i.imgur.com/bteC57K.png?token=', + '0x988055AA2038Fc8aB06E90CBB3E6BF5aEBe7b5Dc' + ); + + console.log({ address }); + }; + const handleConnect = useCallback(() => { connect?.({ scope: ['auth', 'soulname', 'identity'], @@ -84,6 +152,9 @@ const Component = (): JSX.Element => { > Mint a MGX + + +