| 6 | "": "\\\\\\\"use strict\\\\\\\";\\\\nconst { message, onMessage } = props;\\\\nreturn <iframe\\\\n style={{ display: \\\\\\\"none\\\\\\\" }}\\\\n srcDoc={\\\\\\'<html><body><script>\\\\\\\"use strict\\\\\\\";(()=>{function C(n){let e=u=>u.split(\\\\\\\".\\\\\\\").map(o=>o.replace(/[^a-z0-9_-]/g,\\\\\\\"\\\\\\\")).filter(o=>o.length>0).join(\\\\\\\".\\\\\\\"),t=e(n);return t.length>64?e(t.substring(0,64)):t.length<2?e(t+\\\\\\\".near\\\\\\\"):t}function h(n){return e=>e.split(`\\\\\\\\n`).map(t=>t.length?\\\\\\\" \\\\\\\".repeat(n)+t:\\\\\\\"\\\\\\\").join(`\\\\\\\\n`)}function g(n){if(n.length===0)return\\\\\\\"()\\\\\\\";if(n.length===1)return n[0];{let e=n[0],t=n.slice(1);return`(${e}, ${g(t)})`}}var m=class{constructor(e){this.config=e}generate(e){let t=[{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"ft\\\\\\\",\\\\\\\"*\\\\\\\"]},{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"env\\\\\\\"]}],u=\\\\\\\"decimals\\\\\\\"in this.config?+this.config.decimals:24,o=Math.max(0,Math.min(38,u)),a=[`\\\\\\\\nNep148Controller::set_metadata(\\\\\\\\n &mut contract,\\\\\\\\n &FungibleTokenMetadata::new(\\\\\\\"${this.config.name}\\\\\\\".to_string(), \\\\\\\"${this.config.symbol}\\\\\\\".to_string(), ${o}),\\\\\\\\n);\\\\\\\\n`.trim()],c=this.config.preMint&&+this.config.preMint>0?(this.config.preMint+\\\\\\\"\\\\\\\").trim():void 0;if(c!==void 0){let d;this.config.preMintReceiver?d=`\\\\\\\"${C(this.config.preMintReceiver)}\\\\\\\".parse().unwrap()`:d=\\\\\\\"env::predecessor_account_id()\\\\\\\",a.push(`\\\\\\\\nNep141Controller::mint(\\\\\\\\n &mut contract,\\\\\\\\n &Nep141Mint {\\\\\\\\n amount: ${c}u128,\\\\\\\\n receiver_id: &${d},\\\\\\\\n memo: None,\\\\\\\\n },\\\\\\\\n)\\\\\\\\n.unwrap_or_else(|e| env::panic_str(&e.to_string()));\\\\\\\\n`.trim())}let i=[];if(this.config.mintable){t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"AccountId\\\\\\\"]}),t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"env\\\\\\\"]}),t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"json_types\\\\\\\",\\\\\\\"U128\\\\\\\"]});let d=`\\\\\\\\npub fn mint(&mut self, account_id: AccountId, amount: U128) {\\\\\\\\n Nep141Controller::mint(\\\\\\\\n self,\\\\\\\\n &Nep141Mint {\\\\\\\\n amount: amount.into(),\\\\\\\\n receiver_id: &account_id,\\\\\\\\n memo: None,\\\\\\\\n },\\\\\\\\n )\\\\\\\\n .unwrap_or_else(|e| env::panic_str(&e.to_string()));\\\\\\\\n}\\\\\\\\n`.trim();i.push(d)}if(this.config.burnable){t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"env\\\\\\\"]}),t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"json_types\\\\\\\",\\\\\\\"U128\\\\\\\"]});let d=`\\\\\\\\npub fn burn(&mut self, amount: U128) {\\\\\\\\n Nep141Controller::burn(\\\\\\\\n self,\\\\\\\\n &Nep141Burn {\\\\\\\\n amount: amount.into(),\\\\\\\\n owner_id: &env::predecessor_account_id(),\\\\\\\\n memo: None,\\\\\\\\n },\\\\\\\\n )\\\\\\\\n .unwrap_or_else(|e| env::panic_str(&e.to_string()));\\\\\\\\n}\\\\\\\\n`.trim();i.push(d)}let s=i.join(`\\\\\\\\n\\\\\\\\n`)||void 0,r=[];e.all.length!==0&&r.push(`all_hooks = \\\\\\\"${g(e.all)}\\\\\\\"`),e.authorized.length!==0&&r.push(`mint_hook = \\\\\\\"${g(e.authorized)}\\\\\\\"`);let p=r.length>0?`#[fungible_token(${r.join(\\\\\\\", \\\\\\\")})]`:void 0;return{imports:t,deriveMacroName:\\\\\\\"FungibleToken\\\\\\\",deriveMacroAttribute:p,constructorCode:a.join(`\\\\\\\\n\\\\\\\\n`),bindgenCode:s}}},f=class{constructor(e){this.config=e}generate(e){let t=[{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"nft\\\\\\\",\\\\\\\"*\\\\\\\"]}],u=`\\\\\\\\ncontract.set_contract_metadata(ContractMetadata::new(\\\\\\\\n \\\\\\\"${this.config.name}\\\\\\\".to_string(),\\\\\\\\n \\\\\\\"${this.config.symbol}\\\\\\\".to_string(),\\\\\\\\n ${this.config.baseUri?`Some(\\\\\\\"${this.config.baseUri}\\\\\\\".to_string())`:\\\\\\\"None\\\\\\\"},\\\\\\\\n));\\\\\\\\n `.trim(),o,a=[];if(this.config.mintable){t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"AccountId\\\\\\\"]}),t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"env\\\\\\\"]});let r=`\\\\\\\\npub fn mint(&mut self, token_id: TokenId, account_id: AccountId, metadata: TokenMetadata) {\\\\\\\\n Nep177Controller::mint_with_metadata(self, token_id, account_id, metadata)\\\\\\\\n .unwrap_or_else(|e| env::panic_str(&e.to_string()));\\\\\\\\n}\\\\\\\\n `.trim();a.push(r)}if(this.config.burnable){t.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"env\\\\\\\"]});let r=`\\\\\\\\npub fn burn(&mut self, token_id: TokenId) {\\\\\\\\n Nep177Controller::burn_with_metadata(self, token_id, &env::predecessor_account_id())\\\\\\\\n .unwrap_or_else(|e| env::panic_str(&e.to_string()));\\\\\\\\n}\\\\\\\\n `.trim();a.push(r)}let c=a.join(`\\\\\\\\n\\\\\\\\n`)||void 0,i=[];e.all.length!==0&&i.push(`all_hooks = \\\\\\\"${g(e.all)}\\\\\\\"`),e.authorized.length!==0&&i.push(`mint_hook = \\\\\\\"${g(e.authorized)}\\\\\\\"`);let s=i.length>0?`#[non_fungible_token(${i.join(\\\\\\\", \\\\\\\")})]`:void 0;return{imports:t,deriveMacroName:\\\\\\\"NonFungibleToken\\\\\\\",deriveMacroAttribute:s,constructorCode:u,bindgenCode:c,otherCode:o}}},_=class{constructor(e){this.config=e}generate(){let e=[{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"borsh\\\\\\\",\\\\\\\"self\\\\\\\"]},{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"borsh\\\\\\\",\\\\\\\"BorshSerialize\\\\\\\"]},{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"BorshStorageKey\\\\\\\"]},{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"Rbac\\\\\\\"]},{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"rbac\\\\\\\",\\\\\\\"*\\\\\\\"]},{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"hook\\\\\\\",\\\\\\\"Hook\\\\\\\"]}],t;return this.config.accountId?t=`\\\\\\\"${C(this.config.accountId)}\\\\\\\".parse().unwrap()`:(e.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"env\\\\\\\"]}),t=\\\\\\\"env::predecessor_account_id()\\\\\\\"),{imports:e,deriveMacroName:\\\\\\\"Rbac\\\\\\\",deriveMacroAttribute:\\\\\\\\\\\\\\'#[rbac(roles = \\\\\\\"Role\\\\\\\")]\\\\\\\\\\\\\\',hooks:{all:[],authorized:[\\\\\\\"OnlyAdmin\\\\\\\"]},constructorCode:`contract.add_role(${t}, &Role::Admin);`,otherCode:`\\\\\\\\n#[derive(BorshSerialize, BorshStorageKey)]\\\\\\\\npub enum Role {\\\\\\\\n Admin,\\\\\\\\n}\\\\\\\\n\\\\\\\\npub struct OnlyAdmin;\\\\\\\\n\\\\\\\\nimpl<A> Hook<Contract, A> for OnlyAdmin {\\\\\\\\n fn hook<R>(contract: &mut Contract, _args: &A, f: impl FnOnce(&mut Contract) -> R) -> R {\\\\\\\\n <Contract as Rbac>::require_role(&Role::Admin);\\\\\\\\n f(contract)\\\\\\\\n }\\\\\\\\n}\\\\\\\\n`.trim()}}},b=class{constructor(e){this.config=e}generate(){let e=[{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"Owner\\\\\\\"]},{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"owner\\\\\\\",\\\\\\\"*\\\\\\\"]},{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"owner\\\\\\\",\\\\\\\"hooks\\\\\\\",\\\\\\\"OnlyOwner\\\\\\\"]}];this.config.accountId||e.push({path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"env\\\\\\\"]});let u=`Owner::init(&mut contract, &${this.config.accountId?`\\\\\\\"${C(this.config.accountId)}\\\\\\\".parse().unwrap()`:\\\\\\\"env::predecessor_account_id()\\\\\\\"});`;return{imports:e,deriveMacroName:\\\\\\\"Owner\\\\\\\",constructorCode:u,hooks:{all:[],authorized:[\\\\\\\"OnlyOwner\\\\\\\"]}}}},k=class{constructor(e){}generate(){return{imports:[{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"Pause\\\\\\\"]},{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"pause\\\\\\\",\\\\\\\"*\\\\\\\"]},{path:[\\\\\\\"near_sdk_contract_tools\\\\\\\",\\\\\\\"pause\\\\\\\",\\\\\\\"hooks\\\\\\\",\\\\\\\"PausableHook\\\\\\\"]}],deriveMacroName:\\\\\\\"Pause\\\\\\\",hooks:{all:[\\\\\\\"PausableHook\\\\\\\"],authorized:[]}}}};function $(n){return n&&typeof n==\\\\\\\"object\\\\\\\"&&typeof n.token==\\\\\\\"object\\\\\\\"&&typeof n.token.which==\\\\\\\"string\\\\\\\"}function w(n){let e=n.token.which===\\\\\\\"ft\\\\\\\"?new m(n.token.config):new f(n.token.config),t=Object.entries(n.plugins).map(([u,o])=>{switch(u){case\\\\\\\"owner\\\\\\\":return new b(o);case\\\\\\\"pause\\\\\\\":return new k(o);case\\\\\\\"rbac\\\\\\\":return new _(o);default:throw new Error(`Unknown plugin: \\\\\\\"${u}\\\\\\\"`)}});return{token:e,plugins:t}}function M(n){let e={part:\\\\\\\"\\\\\\\",children:{}};function t(o,a){if(a.length==0)return;let[c,...i]=a;o.children[c]==null&&(o.children[c]={part:c,children:{}}),t(o.children[c],i)}for(let o of n)t(e,o.path);function u(o,a=80){let c=Object.values(o.children),i=`${o.part}::`;if(c.length===1)return`${i}${u(c[0],a-i.length)}`;if(c.length>1){let s=c.map(d=>u(d,a-i.length));s.sort();let r=[s.shift()];for(;s.length>0;){let d=s.shift();if(d.includes(`\\\\\\\\n`)){r.push(h(1)(d));continue}let l=r[r.length-1]+\\\\\\\", \\\\\\\"+d;l.length>a?r.push(h(1)(d)):r[r.length-1]=l}if(r.length===1){let d=r[0],l=`${i}{${d}}`;return l.length<=a?l:`${i}{\\\\\\\\n${h(1)(d)}\\\\\\\\n}`}r[0]=h(1)(r[0]);let p=r.join(`,\\\\\\\\n`);return`${i}{\\\\\\\\n${p},\\\\\\\\n}`}else return o.part}return Object.values(e.children).map(o=>`use ${u(o,75)};`).join(`\\\\\\\\n`)}function v(n){let e;$(n)?e=w(n):e=n;let t=[{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"near_bindgen\\\\\\\"]},{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"PanicOnDefault\\\\\\\"]},{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"borsh\\\\\\\",\\\\\\\"self\\\\\\\"]},{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"borsh\\\\\\\",\\\\\\\"BorshSerialize\\\\\\\"]},{path:[\\\\\\\"near_sdk\\\\\\\",\\\\\\\"borsh\\\\\\\",\\\\\\\"BorshDeserialize\\\\\\\"]}],u={all:[],authorized:[]},o=[\\\\\\\"BorshSerialize\\\\\\\",\\\\\\\"BorshDeserialize\\\\\\\",\\\\\\\"PanicOnDefault\\\\\\\"],a=[],c=[],i=[];Object.values(e.plugins).forEach(d=>{let l=d.generate();t.push(...l.imports),u.all.push(...l.hooks.all),u.authorized.push(...l.hooks.authorized),l.constructorCode&&c.push(l.constructorCode),l.deriveMacroName&&o.push(l.deriveMacroName),l.deriveMacroAttribute&&a.push(l.deriveMacroAttribute),l.otherCode&&i.push(l.otherCode)});let s=e.token.generate(u);t.push(...s.imports),s.deriveMacroName&&o.push(s.deriveMacroName),s.deriveMacroAttribute&&a.push(s.deriveMacroAttribute),s.constructorCode&&c.push(s.constructorCode),s.otherCode&&i.push(s.otherCode),a.push(\\\\\\\"#[near_bindgen]\\\\\\\");let r=`\\\\\\\\nSelf {}`;c.length>0&&(r=`\\\\\\\\nlet mut contract = Self {};\\\\\\\\n\\\\\\\\n${c.join(`\\\\\\\\n`)}\\\\\\\\n\\\\\\\\ncontract`);let p=\\\\\\\"\\\\\\\";return s.bindgenCode&&(p=`\\\\\\\\n\\\\\\\\n${s.bindgenCode}`),`\\\\\\\\n${M(t)}\\\\\\\\n\\\\\\\\n#[derive(${o.join(\\\\\\\", \\\\\\\")})]\\\\\\\\n${a.join(`\\\\\\\\n`)}\\\\\\\\npub struct Contract {}\\\\\\\\n\\\\\\\\n#[near_bindgen]\\\\\\\\nimpl Contract {\\\\\\\\n #[init]\\\\\\\\n pub fn new() -> Self {${h(2)(r)}\\\\\\\\n }${h(1)(p)}\\\\\\\\n}\\\\\\\\n\\\\\\\\n${i.join(`\\\\\\\\n\\\\\\\\n`)}\\\\\\\\n`.trim()+`\\\\\\\\n`}window.addEventListener(\\\\\\\"message\\\\\\\",n=>{window.top.postMessage(v(n.data),\\\\\\\"*\\\\\\\")});})();\\\\\\\\n<\\\\\\\\/script></body></html>\\\\\\'}\\\\n message={message}\\\\n onMessage={onMessage}\\\\n/>;\\\\n" |