ATTENTION! This is the test network — don’t send real Toncoin!
Æ Мультикошелек
Введите адрес:
Адрес мультикошелька:
Баланс в TON:
Порог голосования (например 5/6, если для подтверждения требуется 5 из 6 подтверждающих):
Подтверждающие:
Предлагающие:
Идентификатор заявки:
Идентификатор заявки:
Тип заявки:
Идентификатор заявки:
Подтверждающие:
Предлагающие:
Порог голосования:
Идентификатор заявки:
Адрес заявки:
Баланс в TON:
Выполнено:
Одобрено:
Подтверждающие:
Заявка истекает:
Действия:
или отправьте 0,1 TON с комментарием "approve" на адрес заявки.
\ No newline at end of file
+Мультикошелек Ærly Birds
ATTENTION! This is the test network — don’t send real Toncoin!
Æ Мультикошелек
Введите адрес:
Адрес мультикошелька:
Баланс в TON:
Порог голосования (например 5/6, если для подтверждения требуется 5 из 6 подтверждающих):
Подтверждающие:
Предлагающие:
Идентификатор заявки:
Идентификатор заявки:
Тип заявки:
Идентификатор заявки:
Подтверждающие:
Предлагающие:
Порог голосования:
Идентификатор заявки:
Адрес заявки:
Баланс в TON:
Выполнено:
Одобрено:
Подтверждающие:
Заявка истекает:
Действия:
или отправьте 0,1 TON с комментарием "approve" на адрес заявки.
\ No newline at end of file
diff --git a/docs/main.js b/docs/main.js
index d1d4be5..4520eab 100644
--- a/docs/main.js
+++ b/docs/main.js
@@ -1015,4 +1015,4 @@
color: ${e=>e.theme.colors.text.secondary};
`,Tc=Cr(Yn)`
margin-top: 32px;
-`,Oc=e=>{const t=Gn(e),r=nt(Bs),[n,i]=Ze(!0);let o;(null==r?void 0:r.wallet)&&"universalLink"in r.wallet&&("universal-link"===r.wallet.openMethod||L(r.wallet.universalLink)&&On())&&(o=r.wallet.universalLink);const s=()=>{const e=Jr(),t="returnStrategy"in e?e.returnStrategy:Ga.returnStrategy;if(L(o)){const r=!n();i(!1),El(o,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Ga.twaReturnUrl,forceRedirect:r})}else Tr(Bl(o,t))};return kt(Pc,Bt(t,{get children(){return[Qe((()=>e.icon)),kt(Mc,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),kt(Uc,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),kt(Pt,{get when(){return"open-wallet"!==e.showButton},get children(){return kt(Tc,{onClick:()=>e.onClose(),get children(){return kt(Sl,{translationKey:"common.close",children:"Close"})}})}}),kt(Pt,{get when(){return"open-wallet"===e.showButton&&o},get children(){return kt(Tc,{onClick:s,get children(){return kt(Sl,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}}))},Rc=e=>{const t=nt(Bs),[r]=Gi();return kt(Oc,{headerTranslationKey:"actionModal.confirmTransaction.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:r("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.confirmTransaction.text",get icon(){return kt(Mo,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},jc=e=>kt(Oc,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return kt(Bo,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Lc=e=>kt(Oc,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return kt(ko,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),zc=()=>kt(Ai,{get opened(){var e;return Qe((()=>null!==Jr()))()&&!0===(null==(e=Jr())?void 0:e.openModal)},get enableAndroidBackHandler(){return Ga.enableAndroidBackHandler},onClose:()=>Xr(null),"data-tc-actions-modal-container":"true",get children(){return kt(Mt,{get children(){return[kt(Ut,{get when(){return"transaction-sent"===Jr().name},get children(){return kt(Lc,{onClose:()=>Xr(null)})}}),kt(Ut,{get when(){return"transaction-canceled"===Jr().name},get children(){return kt(jc,{onClose:()=>Xr(null)})}}),kt(Ut,{get when(){return"confirm-transaction"===Jr().name},get children(){return kt(Rc,{onClose:()=>Xr(null)})}})]}})}}),Nc=e=>{const t=((e={},t=(navigator.language in e?navigator.language:Object.keys(e)[0]))=>{const[r,n]=Ze(t),[i,o]=bn(e);return[(e,t,n)=>{const o=Zi(i[r()],e,n||"");return"function"==typeof o?o(t):"string"==typeof o?((e,t,r=/{{(.*?)}}/g)=>e.replace(r,((e,r)=>Zi(t,r,""))))(o,t||{}):o},{add(e,t){o(e,(e=>Object.assign(e||{},t)))},locale:e=>e?n(e):r(),dict:e=>Zi(i,e)}]})(en,Ga.language);return customElements.define(kr,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),kt(Wi.Provider,{value:t,get children(){return kt(Bs.Provider,{get value(){return e.tonConnectUI},get children(){return kt(rn.Provider,{get value(){return Ga.connector},get children(){return[kt(Sr,{}),kt(br,{theme:kn,get children(){return[kt(Pt,{get when(){return Ga.buttonRootId},get children(){return kt(rr,{get mount(){return document.getElementById(Ga.buttonRootId)},get children(){return kt(Va,{})}})}}),kt(nr,{component:kr,get children(){return[kt(Ic,{}),kt(zc,{})]}})]}})]}})}})}})},Dc=()=>{setTimeout((()=>qr({status:"opened",closeReason:null})))},$c=e=>{setTimeout((()=>Xr(e)))};class Fc{constructor(e){Ie(this,"connector"),Ie(this,"setConnectRequestParametersCallback"),Ie(this,"consumers",[]),Ie(this,"state",Vr()),this.connector=e.connector,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,Ye((()=>{const e=Vr();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(){return Pe(this,null,(function*(){const e=(yield this.connector.getWallets()).find(ee);return e?this.connectEmbeddedWallet(e):this.connectExternalWallet()}))}close(){var e;e="action-cancelled",setTimeout((()=>qr({status:"closed",closeReason:e})))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Qr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},r=Ga.connectRequestParameters;"loading"===(null==r?void 0:r.state)?this.setConnectRequestParametersCallback(t):t(null==r?void 0:r.value)}connectExternalWallet(){return Pe(this,null,(function*(){return On()&&Rn(),Dc(),new Promise((e=>{const t=this.onStateChange((r=>{const{status:n}=r;"opened"===n&&(t(),e())}))}))}))}}class Kc{constructor(e){Ie(this,"connector"),Ie(this,"consumers",[]),this.connector=e.connector,Ye((()=>{const e=Jr();this.consumers.forEach((t=>t(e)))}))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}}var Hc=r(3515);const Vc="d843619b379084d133f061606beecbf72ae2bf60e0622e808f2a3f631673599b",qc=async(e,t,r)=>{const n=r?"https://testnet.toncenter.com/api/v3/":"https://toncenter.com/api/v3/",i={"Content-Type":"application/json","X-API-Key":Vc},o=await fetch(n+e+"?"+new URLSearchParams(t),{method:"GET",headers:i}),s=await o.json();if(s.error)throw new Error(s.error);return s},Zc=async(e,t,r)=>{const n=r?"https://testnet.tonapi.io/v2/":"https://tonapi.io/v2/",i=await fetch(n+e+"?"+new URLSearchParams(t),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer AHIQH4F4Y4XR6UIAAAAOGYUHWOWLUS6ZIPEXSCLAPOMMD6FSNMPUKHCIJHIP52YTU4VKURA"}}),o=await i.json();if(o.error)throw new Error(o.error);return o};class Wc{constructor(e,t){this.contractAddress=e,this.isTestnet=t,this.tonClient=new Hc.TonClient({endpoint:t?"https://testnet.toncenter.com/api/v2/jsonRPC":"https://toncenter.com/api/v2/jsonRPC",apiKey:Vc})}getState(){throw new Error("Method not implemented.")}get(e,t){return this.tonClient.runMethod(this.contractAddress,e,t)}external(e){throw new Error("Method not implemented.")}internal(e,t){throw new Error("Method not implemented.")}open(e){throw new Error("Method not implemented.")}getTransactions(e,t,r,n){throw new Error("Method not implemented.")}}const Gc=(e,t)=>a.Address.isFriendly(e)?a.Address.parseFriendly(e).isTestOnly&&!t?"Please enter mainnet address":null:"Invalid address",Yc={},Qc=async(e,t)=>{const r=e.toRawString();let n=Yc[r];return n||(n=(await qc("addressBook",{address:r},t))[r].user_friendly,Yc[r]=n),a.Address.parseFriendly(n)},Jc=async(e,t)=>{const r=await Qc(e,t);return Xc(r)},Xc=e=>{const t=ed(e),r=((e,t)=>(a.Address.parseFriendly(e),(t?"https://testnet.tonviewer.com/":"https://tonviewer.com/")+e))(t,e.isTestOnly);return`${t}`},ed=e=>e.address.toString({bounceable:e.isBounceable,testOnly:e.isTestOnly}),td=(e,t)=>e?t?e.equals(t):!e:!t,rd=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r{if(!e)throw console.error(t),new Error(t)},id=e=>{const t=document.createElement("div");return t.innerText=e,t.innerHTML};class od{}od.multisig={new_order:4145565967,execute:1963556701,execute_internal:2737592767},od.order={approve:2808226575,expired:6,approve_rejected:2947491902,approved:2187369462,init:2624846754},od.actions={send_message:4046986843,update_multisig_params:487390163};class sd{}sd.multisig={unauthorized_new_order:1007,invalid_new_order:1008,not_enough_ton:100,unauthorized_execute:101,singers_outdated:102,invalid_dictionary_sequence:103,expired:111},sd.order={unauthorized_init:104,already_approved:107,already_inited:105,unauthorized_sign:106,expired:111,unknown_op:65535,already_executed:112};class ad{}function ld(e){let t=a.Dictionary.empty(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Address());for(let r=0;r0||e.remainingRefs>0)throw new Error("remaining bits in data")}ad.bitsize={op:32,queryId:64,orderSeqno:256,signerIndex:8,actionIndex:8,time:48};class ud{constructor(e,t,r){this.address=e,this.init=t,this.configuration=r,this.orderSeqno=0n}static createFromAddress(e){let t=new ud(e);return t.orderSeqno=0n,t}static createFromConfig(e,t,r=0){const n=function(e){return(0,a.beginCell)().storeUint(0,ad.bitsize.orderSeqno).storeUint(e.threshold,ad.bitsize.signerIndex).storeRef((0,a.beginCell)().storeDictDirect(ld(e.signers))).storeUint(e.signers.length,ad.bitsize.signerIndex).storeDict(ld(e.proposers)).storeBit(e.allowArbitrarySeqno).endCell()}(e),i={code:t,data:n};return new ud((0,a.contractAddress)(r,i),i,e)}async sendDeploy(e,t,r){await e.internal(t,{value:r,sendMode:a.SendMode.PAY_GAS_SEPARATELY,body:(0,a.beginCell)().storeUint(0,ad.bitsize.op).storeUint(0,ad.bitsize.queryId).endCell()})}static packTransferRequest(e){let t=(0,a.beginCell)().store((0,a.storeMessageRelaxed)(e.message)).endCell();return(0,a.beginCell)().storeUint(od.actions.send_message,ad.bitsize.op).storeUint(e.sendMode,8).storeRef(t).endCell()}static packUpdateRequest(e){return(0,a.beginCell)().storeUint(od.actions.update_multisig_params,ad.bitsize.op).storeUint(e.threshold,ad.bitsize.signerIndex).storeRef((0,a.beginCell)().storeDictDirect(ld(e.signers))).storeDict(ld(e.proposers)).endCell()}static packOrder(e){let t=a.Dictionary.empty(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Cell());if(e.length>255)throw new Error("For action chains above 255, use packLarge method");for(let r=0;r{switch(e){case"unlock":return 0;case"out":return 1;case"in":return 2;case"full":return 3;default:throw new Error("Неправильное значение!")}},wd=e=>{switch(e){case"unlock":return"Разблокировать";case"out":return"Исходящие транзакции заблокированы";case"in":return"Входящие транзакции заблокированы";case"full":return"Исходящие и входящие транзакции заблокированы"}};function vd(e){if(e.remainingBits>0||e.remainingRefs>0)throw new Error("remaining bits in data")}class Cd{constructor(e,t){this.address=e,this.init=t}static createFromAddress(e){return new Cd(e)}static createFromConfig(e,t,r=0){const n=function(e){const t=e.jetton_content instanceof a.Cell?e.jetton_content:function(e){return(0,a.beginCell)().storeStringTail(e.uri).endCell()}(e.jetton_content);return(0,a.beginCell)().storeCoins(0).storeAddress(e.admin).storeAddress(null).storeRef(e.wallet_code).storeRef(t).endCell()}(e),i={code:t,data:n};return new Cd((0,a.contractAddress)(r,i),i)}async sendDeploy(e,t,r){await e.internal(t,{value:r,sendMode:a.SendMode.PAY_GAS_SEPARATELY,body:(0,a.beginCell)().storeUint(pd.top_up,32).storeUint(0,64).endCell()})}static mintMessage(e,t,r,n,i,o,s){const l=(0,a.beginCell)().storeUint(pd.internal_transfer,32).storeUint(0,64).storeCoins(t).storeAddress(r).storeAddress(n).storeCoins(o).storeMaybeRef(i).endCell();return(0,a.beginCell)().storeUint(pd.mint,32).storeUint(0,64).storeAddress(e).storeCoins(s).storeRef(l).endCell()}static parseMintInternalMessage(e){if(e.loadUint(32)!==pd.internal_transfer)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadCoins(),n=e.loadAddress(),i=e.loadAddress(),o=e.loadCoins(),s=e.loadBit()?e.loadRef().beginParse():e;return vd(e),{queryId:t,jettonAmount:r,fromAddress:n,responseAddress:i,forwardTonAmount:o,forwardPayload:s}}static parseMintMessage(e){if(e.loadUint(32)!==pd.mint)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadAddress(),n=e.loadCoins(),i=e.loadRef();return vd(e),{queryId:t,toAddress:r,tonAmount:n,internalMessage:this.parseMintInternalMessage(i.beginParse())}}static topUpMessage(){return(0,a.beginCell)().storeUint(pd.top_up,32).storeUint(0,64).endCell()}static parseTopUp(e){if(e.loadUint(32)!==pd.top_up)throw new Error("Invalid op");const t=e.loadUint(64);return vd(e),{queryId:t}}static changeAdminMessage(e){return(0,a.beginCell)().storeUint(pd.change_admin,32).storeUint(0,64).storeAddress(e).endCell()}static parseChangeAdmin(e){if(e.loadUint(32)!==pd.change_admin)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadAddress();return vd(e),{queryId:t,newAdminAddress:r}}static claimAdminMessage(e=0n){return(0,a.beginCell)().storeUint(pd.claim_admin,32).storeUint(e,64).endCell()}static parseClaimAdmin(e){if(e.loadUint(32)!==pd.claim_admin)throw new Error("Invalid op");const t=e.loadUint(64);return vd(e),{queryId:t}}static changeContentMessage(e){const t=e.uri;return(0,a.beginCell)().storeUint(pd.change_metadata_url,32).storeUint(0,64).storeStringTail(t).endCell()}static parseChangeContent(e){if(e.loadUint(32)!==pd.change_metadata_url)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadStringTail();return vd(e),{queryId:t,newMetadataUrl:r}}static lockWalletMessage(e,t,r,n=0){return(0,a.beginCell)().storeUint(pd.call_to,32).storeUint(n,64).storeAddress(e).storeCoins(r).storeRef((0,a.beginCell)().storeUint(pd.set_status,32).storeUint(n,64).storeUint(t,4).endCell()).endCell()}static parseSetStatus(e){if(e.loadUint(32)!==pd.set_status)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadUint(4);return vd(e),{queryId:t,newStatus:r}}static parseCallTo(e,t){if(e.loadUint(32)!==pd.call_to)throw new Error("Invalid op");const r=e.loadUint(64),n=e.loadAddress(),i=e.loadCoins(),o=e.loadRef();return vd(e),{queryId:r,toAddress:n,tonAmount:i,action:t(o.beginParse())}}static forceTransferMessage(e,t,r,n,i,o,s,l,c=0n){const d=md.transferMessage(e,t,n,i,o,s);return(0,a.beginCell)().storeUint(pd.call_to,32).storeUint(c,64).storeAddress(r).storeCoins(l).storeRef(d).endCell()}static parseTransfer(e){if(e.loadUint(32)!==pd.transfer)throw new Error("Invalid op");return{queryId:e.loadUint(64),jettonAmount:e.loadCoins(),toAddress:e.loadAddress(),responseAddress:e.loadAddress(),customPayload:e.loadMaybeRef(),forwardTonAmount:e.loadCoins(),forwardPayload:e.loadBit()?e.loadRef().beginParse():e}}static forceBurnMessage(e,t,r,n,i=0){return(0,a.beginCell)().storeUint(pd.call_to,32).storeUint(i,64).storeAddress(t).storeCoins(n).storeRef(md.burnMessage(e,r,null)).endCell()}static parseBurn(e){if(e.loadUint(32)!==pd.burn)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadCoins(),n=e.loadAddress(),i=e.loadMaybeRef();return vd(e),{queryId:t,jettonAmount:r,responseAddress:n,customPayload:i}}static upgradeMessage(e,t,r=0){return(0,a.beginCell)().storeUint(pd.upgrade,32).storeUint(r,64).storeRef(t).storeRef(e).endCell()}static parseUpgrade(e){if(e.loadUint(32)!==pd.upgrade)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadRef(),n=e.loadRef();return vd(e),{queryId:t,newData:r,newCode:n}}async getWalletAddress(e,t){const r=await e.get("get_wallet_address",[{type:"slice",cell:(0,a.beginCell)().storeAddress(t).endCell()}]);return nd(1===r.stack.remaining,"invalid get_wallet_address result"),r.stack.readAddress()}async getJettonData(e){let t=await e.get("get_jetton_data",[]);return nd(5===t.stack.remaining,"invalid get_jetton_data result"),{totalSupply:t.stack.readBigNumber(),mintable:t.stack.readBoolean(),adminAddress:t.stack.readAddress(),content:t.stack.readCell(),walletCode:t.stack.readCell()}}async getNextAdminAddress(e){const t=await e.get("get_next_admin_address",[]);return nd(1===t.stack.remaining,"invalid get_next_admin_address result"),t.stack.readAddressOpt()}}const _d=e=>{if(null===e)throw new Error("Invalid number");if(void 0===e)throw new Error("Invalid number");if(isNaN(e))throw new Error("Invalid number");if(e<0)throw new Error("Invalid number")},kd=async(e,t,r,n,i)=>{const o=await qc("account",{address:ed(e)},n);nd("active"===o.status,"Контракт не активен. Если вы только что создали заявку, она должна появиться в течение ~30 секунд."),nd(a.Cell.fromBase64(o.code).equals(t),"Код контракта НЕ совпадает с кодом мультикошелька заявки из этого хранилища");const s=o.balance,l=function(e){const t=e.beginParse(),r=t.loadAddress(),n=t.loadUintBig(256);if(0===t.remainingBits)throw new Error("Order not initialized");const i=t.loadUint(8),o=t.loadBoolean(),s=hd(t.loadRef()),a=t.loadUint(256),l=t.loadUint(8),c=t.loadUint(48),d=t.loadRef();return dd(t),{multisigAddress:r,orderSeqno:n,threshold:i,isExecuted:o,signers:s,approvalsMask:a,approvalsNum:l,expirationDate:c,order:d}}(a.Cell.fromBase64(o.data));_d(l.threshold),nd(l.threshold>0,"Порог голосующих не является положительным"),nd(l.threshold<=l.signers.length,"Недопустимый порог"),_d(l.approvalsMask),_d(l.approvalsNum),nd(l.approvalsNum<=l.signers.length,"Неправильное количество"),_d(l.expirationDate);const c=[];for(const e of l.signers)c.push(await Qc(e,n));nd(l.multisigAddress.equals(r.address.address),"Адрес мультикошелька не найден");const d=fd.createFromConfig({multisig:r.address.address,orderSeqno:l.orderSeqno},t);if(nd(d.address.equals(e.address),"Неправильный адрес заявки"),l.isExecuted||(nd(r.threshold<=l.threshold,"Количество подтверждающих не соответствует порогу заявки"),nd(rd(r.signers.map((e=>e.address)),l.signers),"Количество подтверждающих не совпадает с количествои в заявке")),i){const t=new Wc(e.address,n),r=fd.createFromAddress(e.address),i=await r.getOrderDataStrict(t);nd(i.multisig.equals(l.multisigAddress),"Invalid multisigAddress"),nd(i.order_seqno===l.orderSeqno,"Invalid orderSeqno"),nd(i.threshold===l.threshold,"Invalid threshold"),nd(i.executed===l.isExecuted,"Invalid isExecuted"),nd(rd(i.signers,l.signers),"Invalid signers"),nd(i._approvals===BigInt(l.approvalsMask),"Invalid approvalsMask"),nd(i.approvals_num===l.approvalsNum,"Invalid approvalsNum"),nd(i.expiration_date===BigInt(l.expirationDate),"Invalid expirationDate"),nd(i.order.hash().equals(l.order.hash()),"Invalid order")}const u=fd.createFromConfig({multisig:l.multisigAddress,orderSeqno:l.orderSeqno},t).address.equals(e.address),h=a.Dictionary.loadDirect(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Cell(),l.order),f=async e=>{try{const t=e.beginParse();if(0===t.remainingBits&&0==t.remainingRefs)return"Отправьте TON с помощью мультикошелька без комментариев"}catch(e){}try{const t=e.beginParse();if(0==t.loadUint(32)){const e=t.loadStringTail();return`Отправьте TON с помощью мультикошелька с комментарием "${id(e)}"`}}catch(e){}try{const t=e.beginParse(),r=Cd.parseMintMessage(t);nd(0===r.internalMessage.forwardPayload.remainingBits&&0===r.internalMessage.forwardPayload.remainingRefs,"Полезная нагрузка выпуска не поддерживается");const i=await Jc(r.toAddress,n);return`Выпустить ${r.internalMessage.jettonAmount} жетонов (в единицах измерения) на адрес ${i}; ${(0,a.fromNano)(r.tonAmount)} TON для оплаты газа`}catch(e){}try{const t=e.beginParse();return Cd.parseTopUp(t),"Пополнить"}catch(e){}try{const t=e.beginParse(),r=Cd.parseChangeAdmin(t);return`Смена адреса администратора на ${await Jc(r.newAdminAddress,n)}`}catch(e){}try{const t=e.beginParse();return Cd.parseClaimAdmin(t),"Запросить адрес администратора"}catch(e){}try{const t=e.beginParse(),r=Cd.parseChangeContent(t);return`Смена URL метаданных на "${id(r.newMetadataUrl)}"`}catch(e){}try{const t=e.beginParse(),r=Cd.parseTransfer(t);if(r.customPayload)throw new Error("Отправка состояния не поддерживается");nd(0===r.forwardPayload.remainingBits&&0===r.forwardPayload.remainingRefs,"Отправка не поддерживается");const i=await Jc(r.toAddress,n);return`Отправка ${r.jettonAmount} жетонов с адреса мультикошелька на адрес польщователя ${i};`}catch(e){}try{const t=e.beginParse(),r=Cd.parseCallTo(t,Cd.parseSetStatus),i=await Jc(r.toAddress,n),o=(e=>{switch(e){case 0:return"unlock";case 1:return"out";case 2:return"in";case 3:return"full";default:throw new Error("Неправильное значение!")}})(r.action.newStatus);return`Блокировка жетонов пользователя ${i}. Смена состояния "${o}" - "${wd(o)}"; ${(0,a.fromNano)(r.tonAmount)} TON для оплаты газа`}catch(e){}try{const t=e.beginParse(),r=Cd.parseCallTo(t,Cd.parseTransfer);if(r.action.customPayload)throw new Error("Принудительная отправка не поддерживается");nd(0===r.action.forwardPayload.remainingBits&&0===r.action.forwardPayload.remainingRefs,"Принудительная отправка не поддерживается");const i=await Jc(r.toAddress,n),o=await Jc(r.action.toAddress,n);return`Принудительная отправка ${r.action.jettonAmount} с адреса польщователя ${i} на адрес ${o}; ${(0,a.fromNano)(r.tonAmount)} TON for gas`}catch(e){}try{const t=e.beginParse(),r=Cd.parseCallTo(t,Cd.parseBurn);if(r.action.customPayload)throw new Error("Сжигание не поддерживается");const i=await Jc(r.toAddress,n);return`Принудительное сжигание ${r.action.jettonAmount} жетонов с адреса пользователя ${i}; ${(0,a.fromNano)(r.tonAmount)} TON for gas`}catch(e){}throw new Error("Неподдерживаемое действие")};let p=[];const g=h.keys();for(let e of g){let t=`
Действие №${e}:
`;const r=h.get(e).beginParse(),i=r.loadUint(32);if(4046986843===i){const e=r.loadUint(8);let i=[],o=!1;1&e&&i.push("Pays fees separately"),2&e&&i.push("Ignore sending errors"),128&e&&(o=!0,i.push("CARRY ALL BALANCE")),64&e&&i.push("Carry all the remaining value of the inbound message"),32&e&&i.push("DESTROY ACCOUNT");const s=r.loadRef();dd(r);const l=(0,a.loadMessageRelaxed)(s.beginParse());console.log(l);const c=l.info,d=await Jc(c.dest,n);t+=`
Send ${o?"ALL BALANCE":(0,a.fromNano)(c.value.coins)} TON to ${d}
`,t+=`
${await f(l.body)}
`,e&&(t+=`
Send mode: ${i.join(", ")}.
`)}else{if(487390163!==i)throw new Error("Неправильное действие");{const e=r.loadUint(8),i=cd(r.loadRef()),o=r.loadUint(1)?cd(r.loadRef()):[];dd(r),nd(i.length>0,"Invalid new signers"),nd(e>0,"Invalid new threshold"),nd(e<=i.length,"Invalid new threshold"),t+="
`;{const t=!!e.orderInfo&&(new Date).getTime()>e.orderInfo.expiresAt.getTime(),r=t?"Истекший срок заявки ":(e=>{switch(e.type){case"new":return"Новая заяввка";case"execute":return"Execute order";case"pending":return"Ожидаемая заявка";case"executed":return"Выполненная заявка"}throw new Error("unknown order type "+e.type)})(e);let n=`${r} #${e.order.id}`;if("pending"!==e.type||t||(n+=` — ${e.orderInfo.approvalsNum}/${e.orderInfo.threshold}`),"pending"===e.type&&Yu){const t=e.orderInfo.signers.findIndex((e=>e.address.equals(Yu)));if(t>-1){const r=1<${n}`}};let d="",u=!1,h=!1;for(const e of s)"executed"==e.type?h||(d+='
Старые заявки:
',h=!0):"pending"===e.type&&(u||(d+='
Ожидаемые заявки:
',u=!0)),d+=c(e);Fu("#mainScreen_ordersList").innerHTML=d,(".multisig_lastOrder",document.querySelectorAll(".multisig_lastOrder")).forEach((e=>{e.addEventListener("click",(e=>{const t=e.currentTarget.attributes,r=t.getNamedItem("order-address").value,n=BigInt(t.getNamedItem("order-id").value);ph(n,r)}))}))},oh=async(e,t)=>{try{const r=await(async(e,t,r,n,i,o)=>{const s=await qc("account",{address:ed(e)},n);nd("active"===s.status,"Contract not active. If you have just created a multisig it should appear within ~30 seconds."),nd(a.Cell.fromBase64(s.code).equals(t),"The contract code DOES NOT match the multisig code from this repository");const l=s.balance,c=function(e){const t=e.beginParse(),r=t.loadUintBig(256),n=t.loadUint(8),i=cd(t.loadRef()),o=t.loadUint(8),s=cd(t.loadMaybeRef()),a=t.loadBit();return dd(t),{nextOderSeqno:r,threshold:n,signers:i,signersCount:o,proposers:s,allowArbitraryOrderSeqno:a}}(a.Cell.fromBase64(s.data));c.allowArbitraryOrderSeqno&&nd(c.nextOderSeqno===BigInt(0),"invalid nextOrderSeqno for allowArbitraryOrderSeqno");const d=c.signers,u=c.proposers;nd(d.length===c.signersCount,"invalid signersCount"),nd(c.threshold>0,"threshold <= 0"),nd(c.threshold<=c.signersCount,"invalid threshold");const h=[];for(const e of d)h.push(await Qc(e,n));const f=[];for(const e of u)f.push(await Qc(e,n));const p=ud.createFromAddress(e.address),g=new Wc(e.address,n);if(o){const e=await p.getMultisigData(g);c.allowArbitraryOrderSeqno?nd(e.nextOrderSeqno===BigInt(-1),"nextOderSeqno doesn't match"):nd(e.nextOrderSeqno===c.nextOderSeqno,"nextOderSeqno doesn't match"),nd(e.threshold===BigInt(c.threshold),"threshold doesn't match"),nd(rd(e.signers,c.signers),"invalid signers"),nd(rd(e.proposers,c.proposers),"invalid proposers")}const m=ud.createFromConfig({threshold:c.threshold,signers:c.signers,proposers:c.proposers,allowArbitrarySeqno:c.allowArbitraryOrderSeqno},t).address.equals(e.address),y={address:e,multisigContract:p,provider:g,signers:h,proposers:f,threshold:c.threshold,allowArbitraryOrderSeqno:c.allowArbitraryOrderSeqno,nextOderSeqno:c.nextOderSeqno,tonBalance:l,lastOrders:[],stateInitMatches:m};let b=[];if("none"!==i){const t=await qc("transactions",{account:ed(e),limit:256},n);for(const i of t.transactions){if(!i.in_msg.message_content)continue;if(!i.in_msg.message_content.body)continue;const t=a.Cell.fromBase64(i.in_msg.message_content.body).beginParse();if(t.remainingBits<32)continue;const o=t.loadUint(32);if(1963556701===o)try{t.loadUintBig(64);const o=t.loadUintBig(256),s=a.Address.parse(i.in_msg.source),l=fd.createFromConfig({multisig:e.address,orderSeqno:o},r);if(!s.equals(l.address))throw new Error("fake order");b.push({utime:i.now,transactionHash:i.hash,type:"execute",order:{address:{address:s,isBounceable:!0,isTestOnly:n},id:o}})}catch(e){b.push({utime:i.now,transactionHash:i.hash,type:"execute",errorMessage:e.message})}else if(4145565967===o)try{if(1!==i.out_msgs.length)throw new Error("invalid out messages");const o=i.out_msgs[0],{orderAddress:s,orderId:l}=Sd(o),c=fd.createFromConfig({multisig:e.address,orderSeqno:l},r);if(!s.equals(c.address))throw new Error("fake order");const d=t.loadUint(64),u=(t.loadUint(256),t.loadUint(1)),h=t.loadUint(8),f=t.loadUint(48),p=t.loadRef().beginParse().loadDictDirect(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Cell());dd(t),console.log("IN",{queryId:d,orderId:l,orderAddress:s.toString(),isSigner:u,index:h,expiredAt:f,order:p}),b.push({utime:i.now,transactionHash:i.hash,type:"new",order:{address:{address:s,isBounceable:!0,isTestOnly:n},id:l}})}catch(e){console.log(e),b.push({utime:i.now,transactionHash:i.hash,type:"new",errorMessage:"Invalid new order: "+e.message})}}if("aggregate"===i){const e={};for(let t of b){if(t.errorMessage)continue;const r=t.order.id.toString();e[r]?"executed"!==e[r].type&&"execute"===t.type&&(e[r].utime=t.utime,e[r].type="executed"):e[r]={utime:t.utime,transactionHash:t.transactionHash,type:"new"===t.type?"pending":"executed",order:t.order}}b=Object.values(e);const t=e=>{if(e.transaction&&!1===e.transaction.success&&"excess"!==e.transaction.in_msg.decoded_op_name)return!0;if(e.children)for(let r of e.children)if(t(r))return!0;return!1};for(const e of b)if("executed"===e.type){const r=xd.from(e.transactionHash,"base64").toString("hex"),i=await Zc("traces/"+r,{},n);t(i)&&(e.errorMessage="Ошибка")}for(const e of b)if("pending"===e.type)try{const t=await kd(e.order.address,r,y,n,!1);e.orderInfo=t,(new Date).getTime()>t.expiresAt.getTime()&&(e.type="executed")}catch(t){e.type="executed",e.errorMessage=t.message}b=b.sort(((e,t)=>e.type===t.type?t.utime-e.utime:"pending"===e.type?-1:1))}}return y.lastOrders=b,y})(a.Address.parseFriendly(e),Ju,Xu,qu,"aggregate",t);if(eh!==e)return;th=r,ih(),Ku(Fu("#multisig_content"),!0),Ku(Fu("#multisig_error"),!1)}catch(r){if(console.error(r),eh!==e)return;!t&&r?.message?.startsWith("Timeout")||(Ku(Fu("#multisig_content"),!1),Ku(Fu("#multisig_error"),!0),Fu("#multisig_error").innerText=r.message)}clearTimeout(rh),rh=setTimeout((()=>oh(e,!1)),5e3),t&&Gu("multisigScreen")},sh=async(e,t)=>{Gu("loadingScreen"),nh(),eh=e,localStorage.setItem("multisigAddress",e),Vu(e,t);const r=a.Address.parseFriendly(eh);r.isBounceable=!0,r.isTestOnly=qu,Fu("#mulisig_address").innerHTML=Xc(r),await oh(e,!0)};let ah,lh;Fu("#multisig_logoutButton").addEventListener("click",(()=>{localStorage.removeItem("multisigAddress"),nh(),Gu("startScreen")})),Fu("#multisig_createNewOrderButton").addEventListener("click",(()=>{Gu("newOrderScreen")})),Fu("#multisig_updateButton").addEventListener("click",(()=>{zh("update")}));let ch=-1;const dh=()=>{ah=void 0,lh=void 0,clearTimeout(ch)},uh=(e,t)=>{Fu("#order_approveButton").innerText=t?e?"Executing..":"Execute":e?"Approving..":"Approve",Fu("#order_approveButton").disabled=e},hh=()=>{const{tonBalance:e,actions:t,isExecuted:r,approvalsNum:n,approvalsMask:i,threshold:o,signers:s,expiresAt:l}=lh,c=(new Date).getTime()>l.getTime();Fu("#order_tonBalance").innerText=(0,a.fromNano)(e)+" TON",Fu("#order_executed").innerText=r?"Да":"Нет",Fu("#order_approvals").innerText=n+"/"+o,Fu("#order_expiresAt").innerText=(c?"❌ ИСТЕКЛО - ":"")+l.toString();let d=!1,u="";for(let e=0;e#${e+1} — ${r} — ${n?"✅":"❌"}${td(t.address,Yu)?Hu:""}`}Fu("#order_signersList").innerHTML=u;let h="";for(const e of t)h+=e;0===t.length?Fu("#order_actionsTitle").innerText="Нет заявок":1===t.length?Fu("#order_actionsTitle").innerText="Заявка:":Fu("#order_actionsTitle").innerText=t.length+" действия:",Fu("#order_actions").innerHTML=h;let f=Number(localStorage.getItem(eh+"_"+ah+"_approve"));Date.now()-f>12e4&&!d&&(f=0,localStorage.removeItem(eh+"_"+ah+"_approve")),uh(!!f,n===o-1),Ku(Fu("#order_approveButton"),!r&&!c&&!d),Ku(Fu("#order_approveNote"),!r&&!c&&!d)},fh=async(e,t,r)=>{try{const n=await kd(e,Xu,th,qu,r);if(ah!==t)return;lh=n,hh(),Ku(Fu("#order_content"),!0),Ku(Fu("#order_error"),!1)}catch(e){if(console.error(e),ah!==t)return;!r&&e?.message?.startsWith("Время истекло")||(Ku(Fu("#order_content"),!1),Ku(Fu("#order_error"),!0),Fu("#order_error").innerText=e.message)}clearTimeout(ch),ch=setTimeout((()=>fh(e,t,!1)),5e3),r&&Gu("orderScreen")},ph=async(e,t)=>{if(!th)throw new Error("setOrderId: нет информации о мультикошельке");if(Gu("loadingScreen"),dh(),ah=e,Vu(eh,e),void 0===t){const r=fd.createFromConfig({multisig:a.Address.parseFriendly(eh).address,orderSeqno:e},Xu);t=Zu(r.address)}Fu("#order_id").innerText="#"+ah;const r=a.Address.parseFriendly(t);r.isBounceable=!0,r.isTestOnly=qu,Fu("#order_address").innerHTML=Xc(r),await fh(r,e,!0)};Fu("#order_backButton").addEventListener("click",(()=>{Vu(eh),dh(),Gu("multisigScreen")})),Fu("#order_approveButton").addEventListener("click",(async()=>{if(!eh)throw new Error("approve !currentMultisigAddress");if(!lh)throw new Error("approve !currentOrderInfo");const e=eh,t=lh;if(!Yu)return void alert("Please connect wallet");if(-1==t.signers.findIndex((e=>e.address.equals(Yu))))return void alert("Вы не можете подтверждать");const r=ed(t.address),n=yh.toString(),i=(0,a.beginCell)().storeUint(0,32).storeStringTail("approve").endCell().toBoc().toString("base64");console.log({orderAddressString:r,amount:n});const o={validUntil:Math.floor(Date.now()/1e3)+60,messages:[{address:r,amount:n,payload:i}]};uh(!0,t.approvalsNum===t.threshold-1),localStorage.setItem(e+"_"+t.orderId+"_approve",Date.now().toString());try{await Qu.sendTransaction(o)}catch(r){console.error(r),localStorage.removeItem(e+"_"+t.orderId+"_approve"),eh===e&&ah===t.orderId&&uh(!1,t.approvalsNum===t.threshold-1)}}));const gh=(e,t,r)=>{const n=t=>({error:e+": "+t}),i=e=>({value:e});if(null==t||""===t)return n("Empty");switch(r){case"TON":return((e,t)=>{try{const r=function(e,t){const r=function(e){let t=1n;for(let r=0;r2)throw Error("Invalid number");let o=i[0],s=i[1];if(o||(o="0"),s||(s="0"),s.length>t)throw Error("Invalid number");for(;s.length{try{const t=BigInt(e);return t<=0?n("Enter positive amount"):i(t)}catch(e){return n("Invalid amount")}})(t);case"Address":if(!a.Address.isFriendly(t))return n("Invalid Address");const e=a.Address.parseFriendly(t);return e.isTestOnly&&!qu?n("Please enter mainnet address"):i(e);case"URL":return t.startsWith("https://")?i(t):n("Invalid URL");case"Status":return yd.indexOf(t)>-1?i(t):n("Invalid status. Please use: "+yd.join(", "))}},mh=(0,a.toNano)("0.2"),yh=(0,a.toNano)("0.1"),bh=(0,a.toNano)("0.05"),wh=async e=>{try{const t=th,r=await Pd(e.jettonMinterAddress,qu,!1);return t.address.address.equals(r.adminAddress)?{value:r}:{error:"Multisig is not admin of this jetton"}}catch(e){return console.error(e),{error:"Jetton-minter check error"}}},vh=async e=>{try{const t=await th.multisigContract.getOrderAddress(th.provider,e);return"uninit"===(await qc("account",{address:t.toRawString()},qu)).status?{value:!0}:{error:`Заявка ${e} уже существует`}}catch(e){return console.error(e),{error:"Possibly connectivity error"}}},Ch=[{name:"Отправить TON",fields:{amount:{name:"Количество TON",type:"TON"},toAddress:{name:"Адрес получения",type:"Address"}},makeMessage:async e=>({toAddress:e.toAddress,tonAmount:e.amount,body:(0,a.beginCell)().endCell()})},{name:"Отправить жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},toAddress:{name:"На адрес",type:"Address"}},makeMessage:async e=>{const t=e.jettonMinterAddress.address,r=th.address.address,n=Cd.createFromAddress(t),i=new Wc(t,qu);return{toAddress:{address:await n.getWalletAddress(i,r),isBounceable:!0,isTestOnly:qu},tonAmount:yh,body:md.transferMessage(e.amount,e.toAddress.address,r,null,0n,null)}}},{name:"Выпустить жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},toAddress:{name:"На адрес",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.mintMessage(e.toAddress.address,e.amount,e.jettonMinterAddress.address,th.address.address,null,0n,bh)})},{name:"Сменить администратора жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},newAdminAddress:{name:"Новый адрес администратора",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.changeAdminMessage(e.newAdminAddress.address)})},{name:"Запросить адрес администратора",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"}},check:async e=>{try{const t=th,r=await Pd(e.jettonMinterAddress,qu,!0);return r.nextAdminAddress&&t.address.address.equals(r.nextAdminAddress)?{value:r}:{error:"Multisig is not next-admin of this jetton"}}catch(e){return console.error(e),{error:"Jetton-minter check error"}}},makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.claimAdminMessage()})},{name:"Пополнить контракт жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество TON",type:"TON"}},makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:e.amount,body:Cd.topUpMessage()})},{name:"Сменить метаданные жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},newMetadataUrl:{name:"Новая URL ссылка с метаданными",type:"URL"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.changeContentMessage({uri:e.newMetadataUrl})})},{name:"Принудительно сжечь жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},fromAddress:{name:"Адрес пользователя",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.forceBurnMessage(e.amount,e.fromAddress.address,th.address.address,bh)})},{name:"Принудительно отправить жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},fromAddress:{name:"С адреса",type:"Address"},toAddress:{name:"На адрес",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.forceTransferMessage(e.amount,e.toAddress.address,e.fromAddress.address,e.jettonMinterAddress.address,null,0n,null,bh)})},{name:"Сменить состояние контракта жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},userAddress:{name:"Адрес пользователя",type:"Address"},newStatus:{name:"Новое состояние (Разблокировать, исх., вход., полная блокировка)",type:"Status"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.lockWalletMessage(e.userAddress.address,bd(e.newStatus),bh)})}],_h=Fu("#newOrder_typeInput");_h.innerHTML=(()=>{let e="";for(let t=0;t${Ch[t].name}`;return e})();const kh=e=>{const t=Ch[e];let r="";for(let n in t.fields)if(t.fields.hasOwnProperty(n)){const i=t.fields[n];if(r+=`
${i.name}:
`,"Status"===i.type){r+=`"}else r+=``}Fu("#newOrder_fieldsContainer").innerHTML=r};_h.addEventListener("change",(e=>{kh(_h.selectedIndex)})),kh(0);let xh,Ah="fill";const Sh=()=>{if(!th)return"";let e=-1n;return th.lastOrders.forEach((t=>{t.order.id>e&&(e=t.order.id)})),-1n===e?"":(e+1n).toString()},Bh=()=>{Ph("fill"),xh=void 0,_h.selectedIndex=0,kh(0),Fu("#newOrder_orderId").value=Sh()},Eh=e=>{Fu("#newOrder_createButton").disabled=e,Fu("#newOrder_backButton").disabled=e},Ih=e=>{const t=_h.selectedIndex,r=Ch[t];_h.disabled=e,Fu("#newOrder_orderId").disabled=e;for(let n in r.fields)r.fields.hasOwnProperty(n)&&(Fu(`#newOrder_${t}_${n}`).disabled=e);Eh(e)},Ph=e=>{"fill"==e?(Ih(!1),Fu("#newOrder_createButton").innerHTML="Создать",Fu("#newOrder_backButton").innerHTML="Назад"):(Ih(!0),Fu("#newOrder_createButton").innerHTML="Отправить транзакцию",Fu("#newOrder_backButton").innerHTML="Отменить"),Ah=e};Fu("#newOrder_createButton").addEventListener("click",(async()=>{if(!Yu)return void alert("Please connect wallet");if("confirm"===Ah){if(!xh)throw new Error("");try{await Qu.sendTransaction({validUntil:Math.floor(Date.now()/1e3)+60,messages:[xh.message]}),eh===Zu(xh.multisigAddress)&&ph(xh.orderId)}catch(e){console.error(e)}return}const e=Mh(Fu("#newOrder_orderId"));if(null==e||e<0)return void alert("Invalid Order ID");const t=_h.selectedIndex,r=Ch[t],n={};for(let e in r.fields)if(r.fields.hasOwnProperty(e)){const i=r.fields[e],o=Fu(`#newOrder_${t}_${e}`).value,s=gh(i.name,o,i.type);if(s.error)return void alert(s.error);n[e]=s.value}Ih(!0);const i=await vh(e);if(i.error)return alert(i.error),void Ph("fill");if(r.check){const e=await r.check(n);if(e.error)return alert(e.error),void Ph("fill")}const o=await r.makeMessage(n),s=th.proposers.findIndex((e=>e.address.equals(Yu))),l=th.signers.findIndex((e=>e.address.equals(Yu)));if(-1===s&&-1===l)return alert("Error: you are not proposer and not signer"),void Ph("fill");const c=l>-1,d=o.toAddress,u=o.tonAmount,h=o.body,f=Math.floor(Date.now()/1e3)+2592e3,p=ud.packOrder([{type:"transfer",sendMode:a.SendMode.PAY_GAS_SEPARATELY,message:{info:{type:"internal",ihrDisabled:!1,bounce:!0,bounced:!1,dest:d.address,value:{coins:u},ihrFee:0n,forwardFee:0n,createdLt:0n,createdAt:0},body:h}}]),g=ud.newOrderMessage(p,f,c,c?l:s,e,0n),m=g.toBoc().toString("base64");console.log({toAddress:d,tonAmount:u,payloadCell:h,message:g,orderId:e});const y=eh,b=mh.toString();xh={multisigAddress:a.Address.parseFriendly(y).address,orderId:e,message:{address:y,amount:b,payload:m}},Ph("confirm"),Eh(!1)})),Fu("#newOrder_backButton").addEventListener("click",(()=>{"fill"==Ah?Gu("multisigScreen"):Ph("fill")}));const Mh=e=>{if(""===e.value)return null;try{return BigInt(e.value)}catch(e){return null}},Uh=Fu("#newMultisig_threshold"),Th=Fu("#newMultisig_orderId");let Oh,Rh,jh="create",Lh="fill";const zh=e=>{jh=e,Gu("newMultisigScreen")},Nh=()=>{if(Lh="fill",Oh={signersCount:0,proposersCount:0},Rh=void 0,Fu("#newMultisig_signersContainer").innerHTML="",Fu("#newMultisig_proposersContainer").innerHTML="",Th.value=Sh(),Uh.value="",Ku(Fu("#newMultisig_orderIdLabel"),"update"===jh),Ku(Fu("#newMultisig_orderId"),"update"===jh),"create"===jh)$h(0),Oh.signersCount=1;else{Oh.signersCount=th.signers.length;for(let e=0;e{const e=Fu("#newMultisig_deleteSigner0");Ku(e,Oh.signersCount>1)},$h=(e,t)=>{const r=document.createElement("div");r.classList.add("address-input"),r.innerHTML=`
`,Fu("#newMultisig_proposersContainer").appendChild(r),Fu(`#newMultisig_proposer${e}`).value=void 0===t?"":t,r.querySelector(`#newMultisig_deleteProposer${e}`).addEventListener("click",Hh)},Kh=e=>{const t=e.target,r=Number(t.id.slice(24));if(isNaN(r))throw new Error;const n=[];for(let e=0;e{const t=e.target,r=Number(t.id.slice(26));if(isNaN(r))throw new Error;const n=[];for(let e=0;e{$h(Oh.signersCount),Oh.signersCount++,Dh()})),Fu("#newMultisig_addProposerButton").addEventListener("click",(async()=>{Fh(Oh.proposersCount),Oh.proposersCount++}));const Vh=()=>{const e="confirm"===Lh;Th.disabled=e,Uh.disabled=e,Ku(Fu("#newMultisig_addSignerButton"),!e),Ku(Fu("#newMultisig_addProposerButton"),!e);for(let t=0;t1)}for(let t=0;t{"fill"===Lh?Gu("create"===jh?"startScreen":"multisigScreen"):(Lh="fill",Vh())}));const qh=e=>{Fu("#newMultisig_createButton").disabled=e,Fu("#newMultisig_createButton").innerText=e?"Проверка..":"confirm"===Lh?"Подтвердить":"update"===jh?"Обновить":"Создать",Fu("#newMultisigScreen").style.pointerEvents=e?"none":"auto"};Fu("#newMultisig_createButton").addEventListener("click",(async()=>{if(!Yu)return void alert("Пожалуйста подключите кошелек");if("confirm"===Lh){try{const e=Rh.orderId,t=Rh.multisigAddress;await Qu.sendTransaction({validUntil:Math.floor(Date.now()/1e3)+60,messages:[Rh.message]}),"update"===jh?eh===Zu(t)&&ph(e):sh(Zu(t))}catch(e){console.error(e)}return}const e=(e=>{if(""===e.value)return null;try{const t=parseInt(e.value);return isNaN(t)?null:t}catch(e){return null}})(Uh);if(null==e||e<=0||e>Oh.signersCount)return void alert("Порог голосования: недопустимое число");let t;if("update"===jh){if(t=Mh(Th),null==t||t<0)return void alert("Invalid order Id");qh(!0);const e=await vh(t);if(qh(!1),e.error)return void alert(e.error)}const r={},n=[];for(let e=0;e{null!=o.splitDepth?(e.storeBit(!0),e.storeUint(o.splitDepth,5)):e.storeBit(!1),null!=o.special?(e.storeBit(!0),e.store(function(e){return t=>{t.storeBit(e.tick),t.storeBit(e.tock)}}(o.special))):e.storeBit(!1),e.storeMaybeRef(o.code),e.storeMaybeRef(o.data),e.storeDict(o.libraries)})(l),Rh={multisigAddress:r,message:{address:r.toString({urlSafe:!0,bounceable:!0,testOnly:qu}),amount:s,stateInit:l.endCell().toBoc().toString("base64")}},Lh="confirm",Vh()}else{const r=th.proposers.findIndex((e=>e.address.equals(Yu))),o=th.signers.findIndex((e=>e.address.equals(Yu)));if(-1===r&&-1===o)return void alert("Error: you are not proposer and not signer");const s=o>-1,l=Math.floor(Date.now()/1e3)+2592e3,c=ud.packOrder([{type:"update",threshold:e,signers:n,proposers:i}]),d=ud.newOrderMessage(c,l,s,s?o:r,t,0n).toBoc().toString("base64"),u=eh,h=yh.toString();Rh={multisigAddress:a.Address.parseFriendly(u).address,orderId:t,message:{address:u,amount:h,payload:d}},Lh="confirm",Vh()}var o}));const Zh=e=>{if(a.Address.isFriendly(e))return a.Address.parseFriendly(e)},Wh=async()=>{nh(),dh();const e=window.location.hash.substring(1);if(e){const{multisigAddress:t,orderId:r}=(e=>{if(e.indexOf("/")>-1){const t=e.split("/");if(2!==t.length)return{};const r=Zh(t[0]);if(void 0===r)return{};const n=(e=>{try{const t=BigInt(e);if(t<0)return;return t}catch(e){return}})(t[1]);return void 0===n?{}:{multisigAddress:r,orderId:n}}return{multisigAddress:Zh(e)}})(e);if(console.log(t,r),void 0===t)alert("Invalid URL"),Gu("startScreen");else{const e=Zu(t.address);await sh(e,r),void 0!==r&&eh===e&&await ph(r,void 0)}}else(()=>{const e=localStorage.getItem("multisigAddress");e?sh(e):Gu("startScreen")})()};Wh(),window.onpopstate=()=>Wh()})()})();
\ No newline at end of file
+`,Oc=e=>{const t=Gn(e),r=nt(Bs),[n,i]=Ze(!0);let o;(null==r?void 0:r.wallet)&&"universalLink"in r.wallet&&("universal-link"===r.wallet.openMethod||L(r.wallet.universalLink)&&On())&&(o=r.wallet.universalLink);const s=()=>{const e=Jr(),t="returnStrategy"in e?e.returnStrategy:Ga.returnStrategy;if(L(o)){const r=!n();i(!1),El(o,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Ga.twaReturnUrl,forceRedirect:r})}else Tr(Bl(o,t))};return kt(Pc,Bt(t,{get children(){return[Qe((()=>e.icon)),kt(Mc,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),kt(Uc,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),kt(Pt,{get when(){return"open-wallet"!==e.showButton},get children(){return kt(Tc,{onClick:()=>e.onClose(),get children(){return kt(Sl,{translationKey:"common.close",children:"Close"})}})}}),kt(Pt,{get when(){return"open-wallet"===e.showButton&&o},get children(){return kt(Tc,{onClick:s,get children(){return kt(Sl,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}}))},Rc=e=>{const t=nt(Bs),[r]=Gi();return kt(Oc,{headerTranslationKey:"actionModal.confirmTransaction.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:r("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.confirmTransaction.text",get icon(){return kt(Mo,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},jc=e=>kt(Oc,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return kt(Bo,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),Lc=e=>kt(Oc,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return kt(ko,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),zc=()=>kt(Ai,{get opened(){var e;return Qe((()=>null!==Jr()))()&&!0===(null==(e=Jr())?void 0:e.openModal)},get enableAndroidBackHandler(){return Ga.enableAndroidBackHandler},onClose:()=>Xr(null),"data-tc-actions-modal-container":"true",get children(){return kt(Mt,{get children(){return[kt(Ut,{get when(){return"transaction-sent"===Jr().name},get children(){return kt(Lc,{onClose:()=>Xr(null)})}}),kt(Ut,{get when(){return"transaction-canceled"===Jr().name},get children(){return kt(jc,{onClose:()=>Xr(null)})}}),kt(Ut,{get when(){return"confirm-transaction"===Jr().name},get children(){return kt(Rc,{onClose:()=>Xr(null)})}})]}})}}),Nc=e=>{const t=((e={},t=(navigator.language in e?navigator.language:Object.keys(e)[0]))=>{const[r,n]=Ze(t),[i,o]=bn(e);return[(e,t,n)=>{const o=Zi(i[r()],e,n||"");return"function"==typeof o?o(t):"string"==typeof o?((e,t,r=/{{(.*?)}}/g)=>e.replace(r,((e,r)=>Zi(t,r,""))))(o,t||{}):o},{add(e,t){o(e,(e=>Object.assign(e||{},t)))},locale:e=>e?n(e):r(),dict:e=>Zi(i,e)}]})(en,Ga.language);return customElements.define(kr,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),kt(Wi.Provider,{value:t,get children(){return kt(Bs.Provider,{get value(){return e.tonConnectUI},get children(){return kt(rn.Provider,{get value(){return Ga.connector},get children(){return[kt(Sr,{}),kt(br,{theme:kn,get children(){return[kt(Pt,{get when(){return Ga.buttonRootId},get children(){return kt(rr,{get mount(){return document.getElementById(Ga.buttonRootId)},get children(){return kt(Va,{})}})}}),kt(nr,{component:kr,get children(){return[kt(Ic,{}),kt(zc,{})]}})]}})]}})}})}})},Dc=()=>{setTimeout((()=>qr({status:"opened",closeReason:null})))},$c=e=>{setTimeout((()=>Xr(e)))};class Fc{constructor(e){Ie(this,"connector"),Ie(this,"setConnectRequestParametersCallback"),Ie(this,"consumers",[]),Ie(this,"state",Vr()),this.connector=e.connector,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,Ye((()=>{const e=Vr();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(){return Pe(this,null,(function*(){const e=(yield this.connector.getWallets()).find(ee);return e?this.connectEmbeddedWallet(e):this.connectExternalWallet()}))}close(){var e;e="action-cancelled",setTimeout((()=>qr({status:"closed",closeReason:e})))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Qr(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},r=Ga.connectRequestParameters;"loading"===(null==r?void 0:r.state)?this.setConnectRequestParametersCallback(t):t(null==r?void 0:r.value)}connectExternalWallet(){return Pe(this,null,(function*(){return On()&&Rn(),Dc(),new Promise((e=>{const t=this.onStateChange((r=>{const{status:n}=r;"opened"===n&&(t(),e())}))}))}))}}class Kc{constructor(e){Ie(this,"connector"),Ie(this,"consumers",[]),this.connector=e.connector,Ye((()=>{const e=Jr();this.consumers.forEach((t=>t(e)))}))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}}var Hc=r(3515);const Vc="d843619b379084d133f061606beecbf72ae2bf60e0622e808f2a3f631673599b",qc=async(e,t,r)=>{const n=r?"https://testnet.toncenter.com/api/v3/":"https://toncenter.com/api/v3/",i={"Content-Type":"application/json","X-API-Key":Vc},o=await fetch(n+e+"?"+new URLSearchParams(t),{method:"GET",headers:i}),s=await o.json();if(s.error)throw new Error(s.error);return s},Zc=async(e,t,r)=>{const n=r?"https://testnet.tonapi.io/v2/":"https://tonapi.io/v2/",i=await fetch(n+e+"?"+new URLSearchParams(t),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer AHIQH4F4Y4XR6UIAAAAOGYUHWOWLUS6ZIPEXSCLAPOMMD6FSNMPUKHCIJHIP52YTU4VKURA"}}),o=await i.json();if(o.error)throw new Error(o.error);return o};class Wc{constructor(e,t){this.contractAddress=e,this.isTestnet=t,this.tonClient=new Hc.TonClient({endpoint:t?"https://testnet.toncenter.com/api/v2/jsonRPC":"https://toncenter.com/api/v2/jsonRPC",apiKey:Vc})}getState(){throw new Error("Method not implemented.")}get(e,t){return this.tonClient.runMethod(this.contractAddress,e,t)}external(e){throw new Error("Method not implemented.")}internal(e,t){throw new Error("Method not implemented.")}open(e){throw new Error("Method not implemented.")}getTransactions(e,t,r,n){throw new Error("Method not implemented.")}}const Gc=(e,t)=>a.Address.isFriendly(e)?a.Address.parseFriendly(e).isTestOnly&&!t?"Please enter mainnet address":null:"Invalid address",Yc={},Qc=async(e,t)=>{const r=e.toRawString();let n=Yc[r];return n||(n=(await qc("addressBook",{address:r},t))[r].user_friendly,Yc[r]=n),a.Address.parseFriendly(n)},Jc=async(e,t)=>{const r=await Qc(e,t);return Xc(r)},Xc=e=>{const t=ed(e),r=((e,t)=>(a.Address.parseFriendly(e),(t?"https://testnet.tonviewer.com/":"https://tonviewer.com/")+e))(t,e.isTestOnly);return`${t}`},ed=e=>e.address.toString({bounceable:e.isBounceable,testOnly:e.isTestOnly}),td=(e,t)=>e?t?e.equals(t):!e:!t,rd=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r{if(!e)throw console.error(t),new Error(t)},id=e=>{const t=document.createElement("div");return t.innerText=e,t.innerHTML};class od{}od.multisig={new_order:4145565967,execute:1963556701,execute_internal:2737592767},od.order={approve:2808226575,expired:6,approve_rejected:2947491902,approved:2187369462,init:2624846754},od.actions={send_message:4046986843,update_multisig_params:487390163};class sd{}sd.multisig={unauthorized_new_order:1007,invalid_new_order:1008,not_enough_ton:100,unauthorized_execute:101,singers_outdated:102,invalid_dictionary_sequence:103,expired:111},sd.order={unauthorized_init:104,already_approved:107,already_inited:105,unauthorized_sign:106,expired:111,unknown_op:65535,already_executed:112};class ad{}function ld(e){let t=a.Dictionary.empty(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Address());for(let r=0;r0||e.remainingRefs>0)throw new Error("remaining bits in data")}ad.bitsize={op:32,queryId:64,orderSeqno:256,signerIndex:8,actionIndex:8,time:48};class ud{constructor(e,t,r){this.address=e,this.init=t,this.configuration=r,this.orderSeqno=0n}static createFromAddress(e){let t=new ud(e);return t.orderSeqno=0n,t}static createFromConfig(e,t,r=0){const n=function(e){return(0,a.beginCell)().storeUint(0,ad.bitsize.orderSeqno).storeUint(e.threshold,ad.bitsize.signerIndex).storeRef((0,a.beginCell)().storeDictDirect(ld(e.signers))).storeUint(e.signers.length,ad.bitsize.signerIndex).storeDict(ld(e.proposers)).storeBit(e.allowArbitrarySeqno).endCell()}(e),i={code:t,data:n};return new ud((0,a.contractAddress)(r,i),i,e)}async sendDeploy(e,t,r){await e.internal(t,{value:r,sendMode:a.SendMode.PAY_GAS_SEPARATELY,body:(0,a.beginCell)().storeUint(0,ad.bitsize.op).storeUint(0,ad.bitsize.queryId).endCell()})}static packTransferRequest(e){let t=(0,a.beginCell)().store((0,a.storeMessageRelaxed)(e.message)).endCell();return(0,a.beginCell)().storeUint(od.actions.send_message,ad.bitsize.op).storeUint(e.sendMode,8).storeRef(t).endCell()}static packUpdateRequest(e){return(0,a.beginCell)().storeUint(od.actions.update_multisig_params,ad.bitsize.op).storeUint(e.threshold,ad.bitsize.signerIndex).storeRef((0,a.beginCell)().storeDictDirect(ld(e.signers))).storeDict(ld(e.proposers)).endCell()}static packOrder(e){let t=a.Dictionary.empty(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Cell());if(e.length>255)throw new Error("For action chains above 255, use packLarge method");for(let r=0;r{switch(e){case"unlock":return 0;case"out":return 1;case"in":return 2;case"full":return 3;default:throw new Error("Неправильное значение!")}},wd=e=>{switch(e){case"unlock":return"Разблокировать";case"out":return"Исходящие транзакции заблокированы";case"in":return"Входящие транзакции заблокированы";case"full":return"Исходящие и входящие транзакции заблокированы"}};function vd(e){if(e.remainingBits>0||e.remainingRefs>0)throw new Error("remaining bits in data")}class Cd{constructor(e,t){this.address=e,this.init=t}static createFromAddress(e){return new Cd(e)}static createFromConfig(e,t,r=0){const n=function(e){const t=e.jetton_content instanceof a.Cell?e.jetton_content:function(e){return(0,a.beginCell)().storeStringTail(e.uri).endCell()}(e.jetton_content);return(0,a.beginCell)().storeCoins(0).storeAddress(e.admin).storeAddress(null).storeRef(e.wallet_code).storeRef(t).endCell()}(e),i={code:t,data:n};return new Cd((0,a.contractAddress)(r,i),i)}async sendDeploy(e,t,r){await e.internal(t,{value:r,sendMode:a.SendMode.PAY_GAS_SEPARATELY,body:(0,a.beginCell)().storeUint(pd.top_up,32).storeUint(0,64).endCell()})}static mintMessage(e,t,r,n,i,o,s){const l=(0,a.beginCell)().storeUint(pd.internal_transfer,32).storeUint(0,64).storeCoins(t).storeAddress(r).storeAddress(n).storeCoins(o).storeMaybeRef(i).endCell();return(0,a.beginCell)().storeUint(pd.mint,32).storeUint(0,64).storeAddress(e).storeCoins(s).storeRef(l).endCell()}static parseMintInternalMessage(e){if(e.loadUint(32)!==pd.internal_transfer)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadCoins(),n=e.loadAddress(),i=e.loadAddress(),o=e.loadCoins(),s=e.loadBit()?e.loadRef().beginParse():e;return vd(e),{queryId:t,jettonAmount:r,fromAddress:n,responseAddress:i,forwardTonAmount:o,forwardPayload:s}}static parseMintMessage(e){if(e.loadUint(32)!==pd.mint)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadAddress(),n=e.loadCoins(),i=e.loadRef();return vd(e),{queryId:t,toAddress:r,tonAmount:n,internalMessage:this.parseMintInternalMessage(i.beginParse())}}static topUpMessage(){return(0,a.beginCell)().storeUint(pd.top_up,32).storeUint(0,64).endCell()}static parseTopUp(e){if(e.loadUint(32)!==pd.top_up)throw new Error("Invalid op");const t=e.loadUint(64);return vd(e),{queryId:t}}static changeAdminMessage(e){return(0,a.beginCell)().storeUint(pd.change_admin,32).storeUint(0,64).storeAddress(e).endCell()}static parseChangeAdmin(e){if(e.loadUint(32)!==pd.change_admin)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadAddress();return vd(e),{queryId:t,newAdminAddress:r}}static claimAdminMessage(e=0n){return(0,a.beginCell)().storeUint(pd.claim_admin,32).storeUint(e,64).endCell()}static parseClaimAdmin(e){if(e.loadUint(32)!==pd.claim_admin)throw new Error("Invalid op");const t=e.loadUint(64);return vd(e),{queryId:t}}static changeContentMessage(e){const t=e.uri;return(0,a.beginCell)().storeUint(pd.change_metadata_url,32).storeUint(0,64).storeStringTail(t).endCell()}static parseChangeContent(e){if(e.loadUint(32)!==pd.change_metadata_url)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadStringTail();return vd(e),{queryId:t,newMetadataUrl:r}}static lockWalletMessage(e,t,r,n=0){return(0,a.beginCell)().storeUint(pd.call_to,32).storeUint(n,64).storeAddress(e).storeCoins(r).storeRef((0,a.beginCell)().storeUint(pd.set_status,32).storeUint(n,64).storeUint(t,4).endCell()).endCell()}static parseSetStatus(e){if(e.loadUint(32)!==pd.set_status)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadUint(4);return vd(e),{queryId:t,newStatus:r}}static parseCallTo(e,t){if(e.loadUint(32)!==pd.call_to)throw new Error("Invalid op");const r=e.loadUint(64),n=e.loadAddress(),i=e.loadCoins(),o=e.loadRef();return vd(e),{queryId:r,toAddress:n,tonAmount:i,action:t(o.beginParse())}}static forceTransferMessage(e,t,r,n,i,o,s,l,c=0n){const d=md.transferMessage(e,t,n,i,o,s);return(0,a.beginCell)().storeUint(pd.call_to,32).storeUint(c,64).storeAddress(r).storeCoins(l).storeRef(d).endCell()}static parseTransfer(e){if(e.loadUint(32)!==pd.transfer)throw new Error("Invalid op");return{queryId:e.loadUint(64),jettonAmount:e.loadCoins(),toAddress:e.loadAddress(),responseAddress:e.loadAddress(),customPayload:e.loadMaybeRef(),forwardTonAmount:e.loadCoins(),forwardPayload:e.loadBit()?e.loadRef().beginParse():e}}static forceBurnMessage(e,t,r,n,i=0){return(0,a.beginCell)().storeUint(pd.call_to,32).storeUint(i,64).storeAddress(t).storeCoins(n).storeRef(md.burnMessage(e,r,null)).endCell()}static parseBurn(e){if(e.loadUint(32)!==pd.burn)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadCoins(),n=e.loadAddress(),i=e.loadMaybeRef();return vd(e),{queryId:t,jettonAmount:r,responseAddress:n,customPayload:i}}static upgradeMessage(e,t,r=0){return(0,a.beginCell)().storeUint(pd.upgrade,32).storeUint(r,64).storeRef(t).storeRef(e).endCell()}static parseUpgrade(e){if(e.loadUint(32)!==pd.upgrade)throw new Error("Invalid op");const t=e.loadUint(64),r=e.loadRef(),n=e.loadRef();return vd(e),{queryId:t,newData:r,newCode:n}}async getWalletAddress(e,t){const r=await e.get("get_wallet_address",[{type:"slice",cell:(0,a.beginCell)().storeAddress(t).endCell()}]);return nd(1===r.stack.remaining,"invalid get_wallet_address result"),r.stack.readAddress()}async getJettonData(e){let t=await e.get("get_jetton_data",[]);return nd(5===t.stack.remaining,"invalid get_jetton_data result"),{totalSupply:t.stack.readBigNumber(),mintable:t.stack.readBoolean(),adminAddress:t.stack.readAddress(),content:t.stack.readCell(),walletCode:t.stack.readCell()}}async getNextAdminAddress(e){const t=await e.get("get_next_admin_address",[]);return nd(1===t.stack.remaining,"invalid get_next_admin_address result"),t.stack.readAddressOpt()}}const _d=e=>{if(null===e)throw new Error("Invalid number");if(void 0===e)throw new Error("Invalid number");if(isNaN(e))throw new Error("Invalid number");if(e<0)throw new Error("Invalid number")},kd=async(e,t,r,n,i)=>{const o=await qc("account",{address:ed(e)},n);nd("active"===o.status,"Контракт не активен. Если вы только что создали заявку, она должна появиться в течение ~30 секунд."),nd(a.Cell.fromBase64(o.code).equals(t),"Код контракта НЕ совпадает с кодом мультикошелька заявки из этого хранилища");const s=o.balance,l=function(e){const t=e.beginParse(),r=t.loadAddress(),n=t.loadUintBig(256);if(0===t.remainingBits)throw new Error("Order not initialized");const i=t.loadUint(8),o=t.loadBoolean(),s=hd(t.loadRef()),a=t.loadUint(256),l=t.loadUint(8),c=t.loadUint(48),d=t.loadRef();return dd(t),{multisigAddress:r,orderSeqno:n,threshold:i,isExecuted:o,signers:s,approvalsMask:a,approvalsNum:l,expirationDate:c,order:d}}(a.Cell.fromBase64(o.data));_d(l.threshold),nd(l.threshold>0,"Порог голосующих не является положительным"),nd(l.threshold<=l.signers.length,"Недопустимый порог"),_d(l.approvalsMask),_d(l.approvalsNum),nd(l.approvalsNum<=l.signers.length,"Неправильное количество"),_d(l.expirationDate);const c=[];for(const e of l.signers)c.push(await Qc(e,n));nd(l.multisigAddress.equals(r.address.address),"Адрес мультикошелька не найден");const d=fd.createFromConfig({multisig:r.address.address,orderSeqno:l.orderSeqno},t);if(nd(d.address.equals(e.address),"Неправильный адрес заявки"),l.isExecuted||(nd(r.threshold<=l.threshold,"Количество подтверждающих не соответствует порогу заявки"),nd(rd(r.signers.map((e=>e.address)),l.signers),"Количество подтверждающих не совпадает с количествои в заявке")),i){const t=new Wc(e.address,n),r=fd.createFromAddress(e.address),i=await r.getOrderDataStrict(t);nd(i.multisig.equals(l.multisigAddress),"Invalid multisigAddress"),nd(i.order_seqno===l.orderSeqno,"Invalid orderSeqno"),nd(i.threshold===l.threshold,"Invalid threshold"),nd(i.executed===l.isExecuted,"Invalid isExecuted"),nd(rd(i.signers,l.signers),"Invalid signers"),nd(i._approvals===BigInt(l.approvalsMask),"Invalid approvalsMask"),nd(i.approvals_num===l.approvalsNum,"Invalid approvalsNum"),nd(i.expiration_date===BigInt(l.expirationDate),"Invalid expirationDate"),nd(i.order.hash().equals(l.order.hash()),"Invalid order")}const u=fd.createFromConfig({multisig:l.multisigAddress,orderSeqno:l.orderSeqno},t).address.equals(e.address),h=a.Dictionary.loadDirect(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Cell(),l.order),f=async e=>{try{const t=e.beginParse();if(0===t.remainingBits&&0==t.remainingRefs)return"Отправьте TON с помощью мультикошелька без комментариев"}catch(e){}try{const t=e.beginParse();if(0==t.loadUint(32)){const e=t.loadStringTail();return`Отправьте TON с помощью мультикошелька с комментарием "${id(e)}"`}}catch(e){}try{const t=e.beginParse(),r=Cd.parseMintMessage(t);nd(0===r.internalMessage.forwardPayload.remainingBits&&0===r.internalMessage.forwardPayload.remainingRefs,"Полезная нагрузка выпуска не поддерживается");const i=await Jc(r.toAddress,n);return`Выпустить ${r.internalMessage.jettonAmount} жетонов (в единицах измерения) на адрес ${i}; ${(0,a.fromNano)(r.tonAmount)} TON для оплаты газа`}catch(e){}try{const t=e.beginParse();return Cd.parseTopUp(t),"Пополнить"}catch(e){}try{const t=e.beginParse(),r=Cd.parseChangeAdmin(t);return`Смена адреса администратора на ${await Jc(r.newAdminAddress,n)}`}catch(e){}try{const t=e.beginParse();return Cd.parseClaimAdmin(t),"Запросить адрес администратора"}catch(e){}try{const t=e.beginParse(),r=Cd.parseChangeContent(t);return`Смена URL метаданных на "${id(r.newMetadataUrl)}"`}catch(e){}try{const t=e.beginParse(),r=Cd.parseTransfer(t);if(r.customPayload)throw new Error("Отправка состояния не поддерживается");nd(0===r.forwardPayload.remainingBits&&0===r.forwardPayload.remainingRefs,"Отправка не поддерживается");const i=await Jc(r.toAddress,n);return`Отправка ${r.jettonAmount} жетонов с адреса мультикошелька на адрес польщователя ${i};`}catch(e){}try{const t=e.beginParse(),r=Cd.parseCallTo(t,Cd.parseSetStatus),i=await Jc(r.toAddress,n),o=(e=>{switch(e){case 0:return"unlock";case 1:return"out";case 2:return"in";case 3:return"full";default:throw new Error("Неправильное значение!")}})(r.action.newStatus);return`Блокировка жетонов пользователя ${i}. Смена состояния "${o}" - "${wd(o)}"; ${(0,a.fromNano)(r.tonAmount)} TON для оплаты газа`}catch(e){}try{const t=e.beginParse(),r=Cd.parseCallTo(t,Cd.parseTransfer);if(r.action.customPayload)throw new Error("Принудительная отправка не поддерживается");nd(0===r.action.forwardPayload.remainingBits&&0===r.action.forwardPayload.remainingRefs,"Принудительная отправка не поддерживается");const i=await Jc(r.toAddress,n),o=await Jc(r.action.toAddress,n);return`Принудительная отправка ${r.action.jettonAmount} с адреса польщзвателя ${i} на адрес ${o}; ${(0,a.fromNano)(r.tonAmount)} TON for gas`}catch(e){}try{const t=e.beginParse(),r=Cd.parseCallTo(t,Cd.parseBurn);if(r.action.customPayload)throw new Error("Сжигание не поддерживается");const i=await Jc(r.toAddress,n);return`Принудительное сжигание ${r.action.jettonAmount} жетонов с адреса пользователя ${i}; ${(0,a.fromNano)(r.tonAmount)} TON for gas`}catch(e){}throw new Error("Неподдерживаемое действие")};let p=[];const g=h.keys();for(let e of g){let t=`
Действие №${e}:
`;const r=h.get(e).beginParse(),i=r.loadUint(32);if(4046986843===i){const e=r.loadUint(8);let i=[],o=!1;1&e&&i.push("Комиссии оплачиваются отдельно"),2&e&&i.push("Игнорировать ошибки отправки"),128&e&&(o=!0,i.push("Сохранить весь баланс")),64&e&&i.push("Перенесите все оставшееся значение входящего сообщения"),32&e&&i.push("УНИЧТОЖИТЬ УЧЕТНУЮ ЗАПИСЬ");const s=r.loadRef();dd(r);const l=(0,a.loadMessageRelaxed)(s.beginParse());console.log(l);const c=l.info,d=await Jc(c.dest,n);t+=`
Отправить ${o?"ВЕСЬ БАЛАНС":(0,a.fromNano)(c.value.coins)} TON на адрес ${d}
`,t+=`
${await f(l.body)}
`,e&&(t+=`
Метод отправки: ${i.join(", ")}.
`)}else{if(487390163!==i)throw new Error("Неправильное действие");{const e=r.loadUint(8),i=cd(r.loadRef()),o=r.loadUint(1)?cd(r.loadRef()):[];dd(r),nd(i.length>0,"Неправильный адрес подписывающего"),nd(e>0,"Неправильный новый порог"),nd(e<=i.length,"Неправильный порог"),t+="
`;{const t=!!e.orderInfo&&(new Date).getTime()>e.orderInfo.expiresAt.getTime(),r=t?"Истекший срок заявки ":(e=>{switch(e.type){case"new":return"Новая заяввка";case"execute":return"Execute order";case"pending":return"Ожидаемая заявка";case"executed":return"Выполненная заявка"}throw new Error("unknown order type "+e.type)})(e);let n=`${r} #${e.order.id}`;if("pending"!==e.type||t||(n+=` — ${e.orderInfo.approvalsNum}/${e.orderInfo.threshold}`),"pending"===e.type&&Yu){const t=e.orderInfo.signers.findIndex((e=>e.address.equals(Yu)));if(t>-1){const r=1<${n}`}};let d="",u=!1,h=!1;for(const e of s)"executed"==e.type?h||(d+='
Старые заявки:
',h=!0):"pending"===e.type&&(u||(d+='
Ожидаемые заявки:
',u=!0)),d+=c(e);Fu("#mainScreen_ordersList").innerHTML=d,(".multisig_lastOrder",document.querySelectorAll(".multisig_lastOrder")).forEach((e=>{e.addEventListener("click",(e=>{const t=e.currentTarget.attributes,r=t.getNamedItem("order-address").value,n=BigInt(t.getNamedItem("order-id").value);ph(n,r)}))}))},oh=async(e,t)=>{try{const r=await(async(e,t,r,n,i,o)=>{const s=await qc("account",{address:ed(e)},n);nd("active"===s.status,"Contract not active. If you have just created a multisig it should appear within ~30 seconds."),nd(a.Cell.fromBase64(s.code).equals(t),"The contract code DOES NOT match the multisig code from this repository");const l=s.balance,c=function(e){const t=e.beginParse(),r=t.loadUintBig(256),n=t.loadUint(8),i=cd(t.loadRef()),o=t.loadUint(8),s=cd(t.loadMaybeRef()),a=t.loadBit();return dd(t),{nextOderSeqno:r,threshold:n,signers:i,signersCount:o,proposers:s,allowArbitraryOrderSeqno:a}}(a.Cell.fromBase64(s.data));c.allowArbitraryOrderSeqno&&nd(c.nextOderSeqno===BigInt(0),"invalid nextOrderSeqno for allowArbitraryOrderSeqno");const d=c.signers,u=c.proposers;nd(d.length===c.signersCount,"invalid signersCount"),nd(c.threshold>0,"threshold <= 0"),nd(c.threshold<=c.signersCount,"invalid threshold");const h=[];for(const e of d)h.push(await Qc(e,n));const f=[];for(const e of u)f.push(await Qc(e,n));const p=ud.createFromAddress(e.address),g=new Wc(e.address,n);if(o){const e=await p.getMultisigData(g);c.allowArbitraryOrderSeqno?nd(e.nextOrderSeqno===BigInt(-1),"nextOderSeqno doesn't match"):nd(e.nextOrderSeqno===c.nextOderSeqno,"nextOderSeqno doesn't match"),nd(e.threshold===BigInt(c.threshold),"threshold doesn't match"),nd(rd(e.signers,c.signers),"invalid signers"),nd(rd(e.proposers,c.proposers),"invalid proposers")}const m=ud.createFromConfig({threshold:c.threshold,signers:c.signers,proposers:c.proposers,allowArbitrarySeqno:c.allowArbitraryOrderSeqno},t).address.equals(e.address),y={address:e,multisigContract:p,provider:g,signers:h,proposers:f,threshold:c.threshold,allowArbitraryOrderSeqno:c.allowArbitraryOrderSeqno,nextOderSeqno:c.nextOderSeqno,tonBalance:l,lastOrders:[],stateInitMatches:m};let b=[];if("none"!==i){const t=await qc("transactions",{account:ed(e),limit:256},n);for(const i of t.transactions){if(!i.in_msg.message_content)continue;if(!i.in_msg.message_content.body)continue;const t=a.Cell.fromBase64(i.in_msg.message_content.body).beginParse();if(t.remainingBits<32)continue;const o=t.loadUint(32);if(1963556701===o)try{t.loadUintBig(64);const o=t.loadUintBig(256),s=a.Address.parse(i.in_msg.source),l=fd.createFromConfig({multisig:e.address,orderSeqno:o},r);if(!s.equals(l.address))throw new Error("fake order");b.push({utime:i.now,transactionHash:i.hash,type:"execute",order:{address:{address:s,isBounceable:!0,isTestOnly:n},id:o}})}catch(e){b.push({utime:i.now,transactionHash:i.hash,type:"execute",errorMessage:e.message})}else if(4145565967===o)try{if(1!==i.out_msgs.length)throw new Error("invalid out messages");const o=i.out_msgs[0],{orderAddress:s,orderId:l}=Sd(o),c=fd.createFromConfig({multisig:e.address,orderSeqno:l},r);if(!s.equals(c.address))throw new Error("fake order");const d=t.loadUint(64),u=(t.loadUint(256),t.loadUint(1)),h=t.loadUint(8),f=t.loadUint(48),p=t.loadRef().beginParse().loadDictDirect(a.Dictionary.Keys.Uint(8),a.Dictionary.Values.Cell());dd(t),console.log("IN",{queryId:d,orderId:l,orderAddress:s.toString(),isSigner:u,index:h,expiredAt:f,order:p}),b.push({utime:i.now,transactionHash:i.hash,type:"new",order:{address:{address:s,isBounceable:!0,isTestOnly:n},id:l}})}catch(e){console.log(e),b.push({utime:i.now,transactionHash:i.hash,type:"new",errorMessage:"Invalid new order: "+e.message})}}if("aggregate"===i){const e={};for(let t of b){if(t.errorMessage)continue;const r=t.order.id.toString();e[r]?"executed"!==e[r].type&&"execute"===t.type&&(e[r].utime=t.utime,e[r].type="executed"):e[r]={utime:t.utime,transactionHash:t.transactionHash,type:"new"===t.type?"pending":"executed",order:t.order}}b=Object.values(e);const t=e=>{if(e.transaction&&!1===e.transaction.success&&"excess"!==e.transaction.in_msg.decoded_op_name)return!0;if(e.children)for(let r of e.children)if(t(r))return!0;return!1};for(const e of b)if("executed"===e.type){const r=xd.from(e.transactionHash,"base64").toString("hex"),i=await Zc("traces/"+r,{},n);t(i)&&(e.errorMessage="Ошибка")}for(const e of b)if("pending"===e.type)try{const t=await kd(e.order.address,r,y,n,!1);e.orderInfo=t,(new Date).getTime()>t.expiresAt.getTime()&&(e.type="executed")}catch(t){e.type="executed",e.errorMessage=t.message}b=b.sort(((e,t)=>e.type===t.type?t.utime-e.utime:"pending"===e.type?-1:1))}}return y.lastOrders=b,y})(a.Address.parseFriendly(e),Ju,Xu,qu,"aggregate",t);if(eh!==e)return;th=r,ih(),Ku(Fu("#multisig_content"),!0),Ku(Fu("#multisig_error"),!1)}catch(r){if(console.error(r),eh!==e)return;!t&&r?.message?.startsWith("Timeout")||(Ku(Fu("#multisig_content"),!1),Ku(Fu("#multisig_error"),!0),Fu("#multisig_error").innerText=r.message)}clearTimeout(rh),rh=setTimeout((()=>oh(e,!1)),5e3),t&&Gu("multisigScreen")},sh=async(e,t)=>{Gu("loadingScreen"),nh(),eh=e,localStorage.setItem("multisigAddress",e),Vu(e,t);const r=a.Address.parseFriendly(eh);r.isBounceable=!0,r.isTestOnly=qu,Fu("#mulisig_address").innerHTML=Xc(r),await oh(e,!0)};let ah,lh;Fu("#multisig_logoutButton").addEventListener("click",(()=>{localStorage.removeItem("multisigAddress"),nh(),Gu("startScreen")})),Fu("#multisig_createNewOrderButton").addEventListener("click",(()=>{Gu("newOrderScreen")})),Fu("#multisig_updateButton").addEventListener("click",(()=>{zh("update")}));let ch=-1;const dh=()=>{ah=void 0,lh=void 0,clearTimeout(ch)},uh=(e,t)=>{Fu("#order_approveButton").innerText=t?e?"Executing..":"Execute":e?"Approving..":"Approve",Fu("#order_approveButton").disabled=e},hh=()=>{const{tonBalance:e,actions:t,isExecuted:r,approvalsNum:n,approvalsMask:i,threshold:o,signers:s,expiresAt:l}=lh,c=(new Date).getTime()>l.getTime();Fu("#order_tonBalance").innerText=(0,a.fromNano)(e)+" TON",Fu("#order_executed").innerText=r?"Да":"Нет",Fu("#order_approvals").innerText=n+"/"+o,Fu("#order_expiresAt").innerText=(c?"❌ ИСТЕКЛО - ":"")+l.toString();let d=!1,u="";for(let e=0;e#${e+1} — ${r} — ${n?"✅":"❌"}${td(t.address,Yu)?Hu:""}`}Fu("#order_signersList").innerHTML=u;let h="";for(const e of t)h+=e;0===t.length?Fu("#order_actionsTitle").innerText="Нет заявок":1===t.length?Fu("#order_actionsTitle").innerText="Заявка:":Fu("#order_actionsTitle").innerText=t.length+" действия:",Fu("#order_actions").innerHTML=h;let f=Number(localStorage.getItem(eh+"_"+ah+"_approve"));Date.now()-f>12e4&&!d&&(f=0,localStorage.removeItem(eh+"_"+ah+"_approve")),uh(!!f,n===o-1),Ku(Fu("#order_approveButton"),!r&&!c&&!d),Ku(Fu("#order_approveNote"),!r&&!c&&!d)},fh=async(e,t,r)=>{try{const n=await kd(e,Xu,th,qu,r);if(ah!==t)return;lh=n,hh(),Ku(Fu("#order_content"),!0),Ku(Fu("#order_error"),!1)}catch(e){if(console.error(e),ah!==t)return;!r&&e?.message?.startsWith("Время истекло")||(Ku(Fu("#order_content"),!1),Ku(Fu("#order_error"),!0),Fu("#order_error").innerText=e.message)}clearTimeout(ch),ch=setTimeout((()=>fh(e,t,!1)),5e3),r&&Gu("orderScreen")},ph=async(e,t)=>{if(!th)throw new Error("setOrderId: нет информации о мультикошельке");if(Gu("loadingScreen"),dh(),ah=e,Vu(eh,e),void 0===t){const r=fd.createFromConfig({multisig:a.Address.parseFriendly(eh).address,orderSeqno:e},Xu);t=Zu(r.address)}Fu("#order_id").innerText="#"+ah;const r=a.Address.parseFriendly(t);r.isBounceable=!0,r.isTestOnly=qu,Fu("#order_address").innerHTML=Xc(r),await fh(r,e,!0)};Fu("#order_backButton").addEventListener("click",(()=>{Vu(eh),dh(),Gu("multisigScreen")})),Fu("#order_approveButton").addEventListener("click",(async()=>{if(!eh)throw new Error("approve !currentMultisigAddress");if(!lh)throw new Error("approve !currentOrderInfo");const e=eh,t=lh;if(!Yu)return void alert("Please connect wallet");if(-1==t.signers.findIndex((e=>e.address.equals(Yu))))return void alert("Вы не можете подтверждать");const r=ed(t.address),n=yh.toString(),i=(0,a.beginCell)().storeUint(0,32).storeStringTail("approve").endCell().toBoc().toString("base64");console.log({orderAddressString:r,amount:n});const o={validUntil:Math.floor(Date.now()/1e3)+60,messages:[{address:r,amount:n,payload:i}]};uh(!0,t.approvalsNum===t.threshold-1),localStorage.setItem(e+"_"+t.orderId+"_approve",Date.now().toString());try{await Qu.sendTransaction(o)}catch(r){console.error(r),localStorage.removeItem(e+"_"+t.orderId+"_approve"),eh===e&&ah===t.orderId&&uh(!1,t.approvalsNum===t.threshold-1)}}));const gh=(e,t,r)=>{const n=t=>({error:e+": "+t}),i=e=>({value:e}),o=(e,t)=>{try{const r=function(e,t){const r=function(e){let t=1n;for(let r=0;r2)throw Error("Invalid number");let o=i[0],s=i[1];if(o||(o="0"),s||(s="0"),s.length>t)throw Error("Invalid number");for(;s.length-1?i(t):n("Неправильный статус. Пожалуйста, используйте: "+yd.join(", "))}},mh=(0,a.toNano)("0.2"),yh=(0,a.toNano)("0.1"),bh=(0,a.toNano)("0.05"),wh=async e=>{try{const t=th,r=await Pd(e.jettonMinterAddress,qu,!1);return t.address.address.equals(r.adminAddress)?{value:r}:{error:"Мультикошелек не является администратором этого жетона"}}catch(e){return console.error(e),{error:"Jetton-minter check error"}}},vh=async e=>{try{const t=await th.multisigContract.getOrderAddress(th.provider,e);return"uninit"===(await qc("account",{address:t.toRawString()},qu)).status?{value:!0}:{error:`Заявка ${e} уже существует`}}catch(e){return console.error(e),{error:"Possibly connectivity error"}}},Ch=[{name:"Отправить TON",fields:{amount:{name:"Количество TON",type:"TON"},toAddress:{name:"Адрес получения",type:"Address"}},makeMessage:async e=>({toAddress:e.toAddress,tonAmount:e.amount,body:(0,a.beginCell)().endCell()})},{name:"Отправить жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},toAddress:{name:"На адрес",type:"Address"}},makeMessage:async e=>{const t=e.jettonMinterAddress.address,r=th.address.address,n=Cd.createFromAddress(t),i=new Wc(t,qu);return{toAddress:{address:await n.getWalletAddress(i,r),isBounceable:!0,isTestOnly:qu},tonAmount:yh,body:md.transferMessage(e.amount,e.toAddress.address,r,null,0n,null)}}},{name:"Выпустить жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},toAddress:{name:"На адрес",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.mintMessage(e.toAddress.address,e.amount,e.jettonMinterAddress.address,th.address.address,null,0n,bh)})},{name:"Сменить администратора жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},newAdminAddress:{name:"Новый адрес администратора",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.changeAdminMessage(e.newAdminAddress.address)})},{name:"Запросить адрес администратора",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"}},check:async e=>{try{const t=th,r=await Pd(e.jettonMinterAddress,qu,!0);return r.nextAdminAddress&&t.address.address.equals(r.nextAdminAddress)?{value:r}:{error:"Мультикошелек не является администратором этого жетона"}}catch(e){return console.error(e),{error:"Jetton-minter check error"}}},makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.claimAdminMessage()})},{name:"Пополнить контракт жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество TON",type:"TON"}},makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:e.amount,body:Cd.topUpMessage()})},{name:"Сменить метаданные жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},newMetadataUrl:{name:"Новая URL ссылка с метаданными",type:"URL"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.changeContentMessage({uri:e.newMetadataUrl})})},{name:"Принудительно сжечь жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},fromAddress:{name:"Адрес пользователя",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.forceBurnMessage(e.amount,e.fromAddress.address,th.address.address,bh)})},{name:"Принудительно отправить жетоны",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},amount:{name:"Количество жетонов",type:"Jetton"},fromAddress:{name:"С адреса",type:"Address"},toAddress:{name:"На адрес",type:"Address"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.forceTransferMessage(e.amount,e.toAddress.address,e.fromAddress.address,e.jettonMinterAddress.address,null,0n,null,bh)})},{name:"Сменить состояние контракта жетона",fields:{jettonMinterAddress:{name:"Адрес контракта жетона",type:"Address"},userAddress:{name:"Адрес пользователя",type:"Address"},newStatus:{name:"Новое состояние (Разблокировать, исх., вход., полная блокировка)",type:"Status"}},check:wh,makeMessage:async e=>({toAddress:e.jettonMinterAddress,tonAmount:yh,body:Cd.lockWalletMessage(e.userAddress.address,bd(e.newStatus),bh)})}],_h=Fu("#newOrder_typeInput");_h.innerHTML=(()=>{let e="";for(let t=0;t${Ch[t].name}`;return e})();const kh=e=>{const t=Ch[e];let r="";for(let n in t.fields)if(t.fields.hasOwnProperty(n)){const i=t.fields[n];if(r+=`
${i.name}:
`,"Status"===i.type){r+=`"}else r+=``}Fu("#newOrder_fieldsContainer").innerHTML=r};_h.addEventListener("change",(e=>{kh(_h.selectedIndex)})),kh(0);let xh,Ah="fill";const Sh=()=>{if(!th)return"";let e=-1n;return th.lastOrders.forEach((t=>{t.order.id>e&&(e=t.order.id)})),-1n===e?"":(e+1n).toString()},Bh=()=>{Ph("fill"),xh=void 0,_h.selectedIndex=0,kh(0),Fu("#newOrder_orderId").value=Sh()},Eh=e=>{Fu("#newOrder_createButton").disabled=e,Fu("#newOrder_backButton").disabled=e},Ih=e=>{const t=_h.selectedIndex,r=Ch[t];_h.disabled=e,Fu("#newOrder_orderId").disabled=e;for(let n in r.fields)r.fields.hasOwnProperty(n)&&(Fu(`#newOrder_${t}_${n}`).disabled=e);Eh(e)},Ph=e=>{"fill"==e?(Ih(!1),Fu("#newOrder_createButton").innerHTML="Создать",Fu("#newOrder_backButton").innerHTML="Назад"):(Ih(!0),Fu("#newOrder_createButton").innerHTML="Отправить транзакцию",Fu("#newOrder_backButton").innerHTML="Отменить"),Ah=e};Fu("#newOrder_createButton").addEventListener("click",(async()=>{if(!Yu)return void alert("Please connect wallet");if("confirm"===Ah){if(!xh)throw new Error("");try{await Qu.sendTransaction({validUntil:Math.floor(Date.now()/1e3)+60,messages:[xh.message]}),eh===Zu(xh.multisigAddress)&&ph(xh.orderId)}catch(e){console.error(e)}return}const e=Mh(Fu("#newOrder_orderId"));if(null==e||e<0)return void alert("Invalid Order ID");const t=_h.selectedIndex,r=Ch[t],n={};for(let e in r.fields)if(r.fields.hasOwnProperty(e)){const i=r.fields[e],o=Fu(`#newOrder_${t}_${e}`).value,s=gh(i.name,o,i.type);if(s.error)return void alert(s.error);n[e]=s.value}Ih(!0);const i=await vh(e);if(i.error)return alert(i.error),void Ph("fill");if(r.check){const e=await r.check(n);if(e.error)return alert(e.error),void Ph("fill")}const o=await r.makeMessage(n),s=th.proposers.findIndex((e=>e.address.equals(Yu))),l=th.signers.findIndex((e=>e.address.equals(Yu)));if(-1===s&&-1===l)return alert("Error: you are not proposer and not signer"),void Ph("fill");const c=l>-1,d=o.toAddress,u=o.tonAmount,h=o.body,f=Math.floor(Date.now()/1e3)+2592e3,p=ud.packOrder([{type:"transfer",sendMode:a.SendMode.PAY_GAS_SEPARATELY,message:{info:{type:"internal",ihrDisabled:!1,bounce:!0,bounced:!1,dest:d.address,value:{coins:u},ihrFee:0n,forwardFee:0n,createdLt:0n,createdAt:0},body:h}}]),g=ud.newOrderMessage(p,f,c,c?l:s,e,0n),m=g.toBoc().toString("base64");console.log({toAddress:d,tonAmount:u,payloadCell:h,message:g,orderId:e});const y=eh,b=mh.toString();xh={multisigAddress:a.Address.parseFriendly(y).address,orderId:e,message:{address:y,amount:b,payload:m}},Ph("confirm"),Eh(!1)})),Fu("#newOrder_backButton").addEventListener("click",(()=>{"fill"==Ah?Gu("multisigScreen"):Ph("fill")}));const Mh=e=>{if(""===e.value)return null;try{return BigInt(e.value)}catch(e){return null}},Uh=Fu("#newMultisig_threshold"),Th=Fu("#newMultisig_orderId");let Oh,Rh,jh="create",Lh="fill";const zh=e=>{jh=e,Gu("newMultisigScreen")},Nh=()=>{if(Lh="fill",Oh={signersCount:0,proposersCount:0},Rh=void 0,Fu("#newMultisig_signersContainer").innerHTML="",Fu("#newMultisig_proposersContainer").innerHTML="",Th.value=Sh(),Uh.value="",Ku(Fu("#newMultisig_orderIdLabel"),"update"===jh),Ku(Fu("#newMultisig_orderId"),"update"===jh),"create"===jh)$h(0),Oh.signersCount=1;else{Oh.signersCount=th.signers.length;for(let e=0;e{const e=Fu("#newMultisig_deleteSigner0");Ku(e,Oh.signersCount>1)},$h=(e,t)=>{const r=document.createElement("div");r.classList.add("address-input"),r.innerHTML=`