UNPKG

@aptos-labs/ts-sdk

Version:
2 lines 3.64 kB
import{a as g,f as d,g as C,i as w}from"./chunk-FWPK5KC2.mjs";import{a as I}from"./chunk-MEXWNZY6.mjs";import{b as f}from"./chunk-XHEZAVN3.mjs";import{a as P}from"./chunk-43HKFNUB.mjs";import{d as l}from"./chunk-XXBMHWNV.mjs";import{a as T}from"./chunk-TZCETTAW.mjs";import{c as A,m as s}from"./chunk-S5AGI7RQ.mjs";import{a as r}from"./chunk-YJIRT3GJ.mjs";import{b as y}from"./chunk-5NSXEM3O.mjs";import{b as p}from"./chunk-UEI62FBQ.mjs";async function b(t){let a=await h(t);return x(t,a)}async function h(t){let{aptosConfig:a,data:n}=t,e,o;return"bytecode"in n?o=await g(n):"multisigAddress"in n?(e={aptosConfig:a,multisigAddress:n.multisigAddress,function:n.function,functionArguments:n.functionArguments,typeArguments:n.typeArguments,abi:n.abi},o=await g(e)):(e={aptosConfig:a,function:n.function,functionArguments:n.functionArguments,typeArguments:n.typeArguments,abi:n.abi},o=await g(e)),o}async function x(t,a){let{aptosConfig:n,sender:e,options:o}=t,i;if(D(t)&&(i=p.ZERO.toString()),G(t)){let{secondarySignerAddresses:c}=t;return d({aptosConfig:n,sender:e,payload:a,options:o,secondarySignerAddresses:c,feePayerAddress:i})}return d({aptosConfig:n,sender:e,payload:a,options:o,feePayerAddress:i})}function D(t){return t.withFeePayer===!0}function G(t){return"secondarySignerAddresses"in t}function Q(t){let{transaction:a}=t;return l(a)}function U(t){let{signer:a,transaction:n}=t;return a.signTransactionWithAuthenticator(n)}async function X(t){let{aptosConfig:a,transaction:n,signerPublicKey:e,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:c}=t,u=C({transaction:n,signerPublicKey:e,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:c}),{data:m}=await f({aptosConfig:a,body:u,path:"transactions/simulate",params:{estimate_gas_unit_price:t.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:t.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:t.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return m}async function _(t){let{aptosConfig:a}=t,n=w({...t}),{data:e}=await f({aptosConfig:a,body:n,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return e}async function K(t){let{aptosConfig:a,signer:n,transaction:e}=t,o=U({signer:n,transaction:e});return _({aptosConfig:a,transaction:e,senderAuthenticator:o})}var B={typeParameters:[],parameters:[s.u8(),new s(s.u8())]};async function Y(t){let{aptosConfig:a,account:n,metadataBytes:e,moduleBytecode:o,options:i}=t,c=o.map(u=>r.U8(u));return b({aptosConfig:a,sender:p.from(n),data:{function:"0x1::code::publish_package_txn",functionArguments:[r.U8(e),new r(c)],abi:B},options:i})}var M={typeParameters:[],parameters:[new A,s.u8(),new A,s.u8(),s.u8(),s.u8()]};async function $(t){let{aptosConfig:a,fromAccount:n,toNewPrivateKey:e}=t,o=await I({aptosConfig:a,accountAddress:n.accountAddress}),i=P.fromPrivateKey({privateKey:e,legacy:!0}),u=new T({sequenceNumber:BigInt(o.sequence_number),originator:n.accountAddress,currentAuthKey:p.from(o.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),m=n.sign(u),S=i.sign(u),R=await b({aptosConfig:a,sender:n.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new y(n.signingScheme),r.U8(n.publicKey.toUint8Array()),new y(i.signingScheme),r.U8(i.publicKey.toUint8Array()),r.U8(m.toUint8Array()),r.U8(S.toUint8Array())],abi:M}});return K({aptosConfig:a,signer:n,transaction:R})}export{b as a,h as b,x as c,Q as d,U as e,X as f,_ as g,K as h,Y as i,$ as j}; //# sourceMappingURL=chunk-V6J6AW5T.mjs.map