@vleap/warps 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -24,7 +24,7 @@ type WarpContractAction = {
24
24
  label: string;
25
25
  description: string | null;
26
26
  address: string;
27
- endpoint: string | null;
27
+ func: string | null;
28
28
  args: any[];
29
29
  };
30
30
  type WarpLinkAction = {
@@ -42,7 +42,7 @@ declare const Config: {
42
42
  ApiUrl: (env: ChainEnv) => "https://devnet-api.multiversx.com" | "https://testnet-api.multiversx.com" | "https://api.multiversx.com";
43
43
  };
44
44
  Registry: {
45
- Contract: (env: ChainEnv) => "erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn" | "####";
45
+ Contract: (env: ChainEnv) => "erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn" | "####" | "erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe";
46
46
  };
47
47
  };
48
48
 
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ type WarpContractAction = {
24
24
  label: string;
25
25
  description: string | null;
26
26
  address: string;
27
- endpoint: string | null;
27
+ func: string | null;
28
28
  args: any[];
29
29
  };
30
30
  type WarpLinkAction = {
@@ -42,7 +42,7 @@ declare const Config: {
42
42
  ApiUrl: (env: ChainEnv) => "https://devnet-api.multiversx.com" | "https://testnet-api.multiversx.com" | "https://api.multiversx.com";
43
43
  };
44
44
  Registry: {
45
- Contract: (env: ChainEnv) => "erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn" | "####";
45
+ Contract: (env: ChainEnv) => "erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn" | "####" | "erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe";
46
46
  };
47
47
  };
48
48
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var x=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},I=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of F(r))!q.call(e,o)&&o!==t&&h(e,o,{get:()=>r[o],enumerable:!(i=A(r,o))||i.enumerable});return e};var B=e=>I(h({},"__esModule",{value:!0}),e);var R={};x(R,{Config:()=>s,WarpBuilder:()=>g,WarpLink:()=>m,WarpRegistry:()=>l});module.exports=B(R);var s={ProtocolName:"warp",LatestVersion:"0.1.0",DefaultClientUrl:e=>e==="devnet"?"https://devnet.xwarp.me/to":e==="testnet"?"###Not implemented###":"https://xwarp.me/to",Chain:{ApiUrl:e=>e==="devnet"?"https://devnet-api.multiversx.com":e==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:e=>e==="devnet"?"erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn":"####"}};var c=require("@multiversx/sdk-core");var f=e=>e==="devnet"?"D":e==="testnet"?"T":"1",C=()=>`${s.ProtocolName}:${s.LatestVersion}`;var g=class{config;pendingWarp={protocol:C(),name:"",title:"",description:null,preview:"",actions:[]};constructor(r){this.config=r}createInscriptionTransaction(r){if(!this.config.userAddress)throw new Error("warp builder user address not set");let t=new c.TransactionsFactoryConfig({chainID:f(this.config.env)}),i=new c.TransferTransactionsFactory({config:t}),o=JSON.stringify(r);return i.createTransactionForNativeTokenTransfer({sender:c.Address.newFromBech32(this.config.userAddress),receiver:c.Address.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Buffer.from(o).valueOf()})}createFromRaw(r){return JSON.parse(r)}createFromTransaction(r){return this.createFromRaw(r.data.toString())}async createFromTransactionHash(r){let t=new c.ApiNetworkProvider(this.config.chainApiUrl||s.Chain.ApiUrl(this.config.env));try{let i=await t.getTransaction(r);return this.createFromTransaction(i)}catch(i){return console.error("Error creating warp from transaction hash",i),null}}setName(r){return this.pendingWarp.name=r,this}setTitle(r){return this.pendingWarp.title=r,this}setDescription(r){return this.pendingWarp.description=r,this}setPreview(r){return this.pendingWarp.preview=r,this}setActions(r){return this.pendingWarp.actions=r,this}addAction(r){return this.pendingWarp.actions.push(r),this}build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),this.pendingWarp}ensure(r,t){if(!r)throw new Error(`Warp: ${t}`)}};var n=require("@multiversx/sdk-core/out"),v=require("@multiversx/sdk-core/out/utils.codec");var l=class{config;registerCost;constructor(r){this.config=r,this.registerCost=BigInt(0),this.loadRegistryInfo()}createRegisterTransaction(r,t=null){if(this.registerCost===BigInt(0))throw new Error("registry config not loaded");if(!this.config.userAddress)throw new Error("registry config user address not set");let i=t?this.registerCost*BigInt(2):this.registerCost;return this.getFactory().createTransactionForExecute({sender:n.Address.newFromBech32(this.config.userAddress),contract:n.Address.newFromBech32(s.Registry.Contract(this.config.env)),function:"register",gasLimit:BigInt(1e7),nativeTransferAmount:i,arguments:t?[n.BytesValue.fromHex(r),n.BytesValue.fromUTF8(t)]:[n.BytesValue.fromHex(r)]})}createAliasAssignTransaction(r,t){if(!this.config.userAddress)throw new Error("registry config user address not set");return this.getFactory().createTransactionForExecute({sender:n.Address.newFromBech32(this.config.userAddress),contract:n.Address.newFromBech32(s.Registry.Contract(this.config.env)),function:"assignAlias",gasLimit:BigInt(1e7),arguments:[n.BytesValue.fromUTF8(r),n.BytesValue.fromUTF8(t)]})}async resolveAlias(r){let t=s.Registry.Contract(this.config.env),i=this.getController(),o=i.createQuery({contract:t,function:"resolveAlias",arguments:[n.BytesValue.fromUTF8(r)]}),p=await i.runQuery(o);console.log("resolveAlias res",p);let[a]=i.parseQueryResponse(p);return console.log("resolveAlias txHashRaw",a),(a==null?void 0:a.toString())||null}async loadRegistryInfo(){let r=s.Registry.Contract(this.config.env),t=this.getController(),i=t.createQuery({contract:r,function:"getConfig",arguments:[]}),o=await t.runQuery(i),[p]=t.parseQueryResponse(o),a=BigInt("0x"+(0,v.byteArrayToHex)(p));this.registerCost=a}getFactory(){let r=new n.TransactionsFactoryConfig({chainID:f(this.config.env)});return new n.SmartContractTransactionsFactory({config:r})}getController(){let r=this.config.chainApiUrl||s.Chain.ApiUrl(this.config.env),t=new n.ApiNetworkProvider(r,{timeout:3e4}),i=new n.QueryRunnerAdapter({networkProvider:t});return new n.SmartContractQueriesController({queryRunner:i})}};var y="xwarp",W=":",m=class{constructor(r){this.config=r;this.config=r}build(r,t){return`${this.config.clientUrl||s.DefaultClientUrl(this.config.env)}?${y}=${encodeURIComponent(r)}${W}${encodeURIComponent(t)}`}async detect(r){let o=new URL(r).searchParams.get(y);if(!o)return{match:!1,warp:null};let[p,a]=o.split(W),d=new g(this.config),T=new l(this.config),u=null;if(p==="hash")u=await d.createFromTransactionHash(a);else if(p==="alias"){let w=await T.resolveAlias(a);w&&(u=await d.createFromTransactionHash(w))}return u?{match:!0,warp:u}:{match:!1,warp:null}}};0&&(module.exports={Config,WarpBuilder,WarpLink,WarpRegistry});
1
+ "use strict";var h=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var x=(e,r)=>{for(var t in r)h(e,t,{get:r[t],enumerable:!0})},I=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of A(r))!F.call(e,o)&&o!==t&&h(e,o,{get:()=>r[o],enumerable:!(i=T(r,o))||i.enumerable});return e};var B=e=>I(h({},"__esModule",{value:!0}),e);var R={};x(R,{Config:()=>s,WarpBuilder:()=>g,WarpLink:()=>m,WarpRegistry:()=>l});module.exports=B(R);var s={ProtocolName:"warp",LatestVersion:"0.1.0",DefaultClientUrl:e=>e==="devnet"?"https://devnet.xwarp.me/to":e==="testnet"?"###Not implemented###":"https://xwarp.me/to",Chain:{ApiUrl:e=>e==="devnet"?"https://devnet-api.multiversx.com":e==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:e=>e==="devnet"?"erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn":e==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"}};var c=require("@multiversx/sdk-core");var f=e=>e==="devnet"?"D":e==="testnet"?"T":"1",C=()=>`${s.ProtocolName}:${s.LatestVersion}`;var g=class{config;pendingWarp={protocol:C(),name:"",title:"",description:null,preview:"",actions:[]};constructor(r){this.config=r}createInscriptionTransaction(r){if(!this.config.userAddress)throw new Error("warp builder user address not set");let t=new c.TransactionsFactoryConfig({chainID:f(this.config.env)}),i=new c.TransferTransactionsFactory({config:t}),o=JSON.stringify(r);return i.createTransactionForNativeTokenTransfer({sender:c.Address.newFromBech32(this.config.userAddress),receiver:c.Address.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Buffer.from(o).valueOf()})}createFromRaw(r){return JSON.parse(r)}createFromTransaction(r){return this.createFromRaw(r.data.toString())}async createFromTransactionHash(r){let t=new c.ApiNetworkProvider(this.config.chainApiUrl||s.Chain.ApiUrl(this.config.env));try{let i=await t.getTransaction(r);return this.createFromTransaction(i)}catch(i){return console.error("Error creating warp from transaction hash",i),null}}setName(r){return this.pendingWarp.name=r,this}setTitle(r){return this.pendingWarp.title=r,this}setDescription(r){return this.pendingWarp.description=r,this}setPreview(r){return this.pendingWarp.preview=r,this}setActions(r){return this.pendingWarp.actions=r,this}addAction(r){return this.pendingWarp.actions.push(r),this}build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),this.pendingWarp}ensure(r,t){if(!r)throw new Error(`Warp: ${t}`)}};var n=require("@multiversx/sdk-core/out"),v=require("@multiversx/sdk-core/out/utils.codec");var l=class{config;registerCost;constructor(r){this.config=r,this.registerCost=BigInt(0),this.loadRegistryInfo()}createRegisterTransaction(r,t=null){if(this.registerCost===BigInt(0))throw new Error("registry config not loaded");if(!this.config.userAddress)throw new Error("registry config user address not set");let i=t?this.registerCost*BigInt(2):this.registerCost;return this.getFactory().createTransactionForExecute({sender:n.Address.newFromBech32(this.config.userAddress),contract:n.Address.newFromBech32(s.Registry.Contract(this.config.env)),function:"register",gasLimit:BigInt(1e7),nativeTransferAmount:i,arguments:t?[n.BytesValue.fromHex(r),n.BytesValue.fromUTF8(t)]:[n.BytesValue.fromHex(r)]})}createAliasAssignTransaction(r,t){if(!this.config.userAddress)throw new Error("registry config user address not set");return this.getFactory().createTransactionForExecute({sender:n.Address.newFromBech32(this.config.userAddress),contract:n.Address.newFromBech32(s.Registry.Contract(this.config.env)),function:"assignAlias",gasLimit:BigInt(1e7),arguments:[n.BytesValue.fromUTF8(r),n.BytesValue.fromUTF8(t)]})}async resolveAlias(r){let t=s.Registry.Contract(this.config.env),i=this.getController(),o=i.createQuery({contract:t,function:"resolveAlias",arguments:[n.BytesValue.fromUTF8(r)]}),p=await i.runQuery(o);console.log("resolveAlias res",p);let[a]=i.parseQueryResponse(p);return console.log("resolveAlias txHashRaw",a),(a==null?void 0:a.toString())||null}async loadRegistryInfo(){let r=s.Registry.Contract(this.config.env),t=this.getController(),i=t.createQuery({contract:r,function:"getConfig",arguments:[]}),o=await t.runQuery(i),[p]=t.parseQueryResponse(o),a=BigInt("0x"+(0,v.byteArrayToHex)(p));this.registerCost=a}getFactory(){let r=new n.TransactionsFactoryConfig({chainID:f(this.config.env)});return new n.SmartContractTransactionsFactory({config:r})}getController(){let r=this.config.chainApiUrl||s.Chain.ApiUrl(this.config.env),t=new n.ApiNetworkProvider(r,{timeout:3e4}),i=new n.QueryRunnerAdapter({networkProvider:t});return new n.SmartContractQueriesController({queryRunner:i})}};var y="xwarp",W=":",m=class{constructor(r){this.config=r;this.config=r}build(r,t){return`${this.config.clientUrl||s.DefaultClientUrl(this.config.env)}?${y}=${encodeURIComponent(r)}${W}${encodeURIComponent(t)}`}async detect(r){let o=new URL(r).searchParams.get(y);if(!o)return{match:!1,warp:null};let[p,a]=o.split(W),d=new g(this.config),q=new l(this.config),u=null;if(p==="hash")u=await d.createFromTransactionHash(a);else if(p==="alias"){let w=await q.resolveAlias(a);w&&(u=await d.createFromTransactionHash(w))}return u?{match:!0,warp:u}:{match:!1,warp:null}}};0&&(module.exports={Config,WarpBuilder,WarpLink,WarpRegistry});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var i={ProtocolName:"warp",LatestVersion:"0.1.0",DefaultClientUrl:n=>n==="devnet"?"https://devnet.xwarp.me/to":n==="testnet"?"###Not implemented###":"https://xwarp.me/to",Chain:{ApiUrl:n=>n==="devnet"?"https://devnet-api.multiversx.com":n==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:n=>n==="devnet"?"erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn":"####"}};import{Address as w,ApiNetworkProvider as T,TransactionsFactoryConfig as A,TransferTransactionsFactory as F}from"@multiversx/sdk-core";var g=n=>n==="devnet"?"D":n==="testnet"?"T":"1",d=()=>`${i.ProtocolName}:${i.LatestVersion}`;var l=class{config;pendingWarp={protocol:d(),name:"",title:"",description:null,preview:"",actions:[]};constructor(r){this.config=r}createInscriptionTransaction(r){if(!this.config.userAddress)throw new Error("warp builder user address not set");let t=new A({chainID:g(this.config.env)}),e=new F({config:t}),s=JSON.stringify(r);return e.createTransactionForNativeTokenTransfer({sender:w.newFromBech32(this.config.userAddress),receiver:w.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Buffer.from(s).valueOf()})}createFromRaw(r){return JSON.parse(r)}createFromTransaction(r){return this.createFromRaw(r.data.toString())}async createFromTransactionHash(r){let t=new T(this.config.chainApiUrl||i.Chain.ApiUrl(this.config.env));try{let e=await t.getTransaction(r);return this.createFromTransaction(e)}catch(e){return console.error("Error creating warp from transaction hash",e),null}}setName(r){return this.pendingWarp.name=r,this}setTitle(r){return this.pendingWarp.title=r,this}setDescription(r){return this.pendingWarp.description=r,this}setPreview(r){return this.pendingWarp.preview=r,this}setActions(r){return this.pendingWarp.actions=r,this}addAction(r){return this.pendingWarp.actions.push(r),this}build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),this.pendingWarp}ensure(r,t){if(!r)throw new Error(`Warp: ${t}`)}};import{Address as u,ApiNetworkProvider as q,BytesValue as c,QueryRunnerAdapter as x,SmartContractQueriesController as I,SmartContractTransactionsFactory as B,TransactionsFactoryConfig as R}from"@multiversx/sdk-core/out";import{byteArrayToHex as P}from"@multiversx/sdk-core/out/utils.codec";var f=class{config;registerCost;constructor(r){this.config=r,this.registerCost=BigInt(0),this.loadRegistryInfo()}createRegisterTransaction(r,t=null){if(this.registerCost===BigInt(0))throw new Error("registry config not loaded");if(!this.config.userAddress)throw new Error("registry config user address not set");let e=t?this.registerCost*BigInt(2):this.registerCost;return this.getFactory().createTransactionForExecute({sender:u.newFromBech32(this.config.userAddress),contract:u.newFromBech32(i.Registry.Contract(this.config.env)),function:"register",gasLimit:BigInt(1e7),nativeTransferAmount:e,arguments:t?[c.fromHex(r),c.fromUTF8(t)]:[c.fromHex(r)]})}createAliasAssignTransaction(r,t){if(!this.config.userAddress)throw new Error("registry config user address not set");return this.getFactory().createTransactionForExecute({sender:u.newFromBech32(this.config.userAddress),contract:u.newFromBech32(i.Registry.Contract(this.config.env)),function:"assignAlias",gasLimit:BigInt(1e7),arguments:[c.fromUTF8(r),c.fromUTF8(t)]})}async resolveAlias(r){let t=i.Registry.Contract(this.config.env),e=this.getController(),s=e.createQuery({contract:t,function:"resolveAlias",arguments:[c.fromUTF8(r)]}),a=await e.runQuery(s);console.log("resolveAlias res",a);let[o]=e.parseQueryResponse(a);return console.log("resolveAlias txHashRaw",o),(o==null?void 0:o.toString())||null}async loadRegistryInfo(){let r=i.Registry.Contract(this.config.env),t=this.getController(),e=t.createQuery({contract:r,function:"getConfig",arguments:[]}),s=await t.runQuery(e),[a]=t.parseQueryResponse(s),o=BigInt("0x"+P(a));this.registerCost=o}getFactory(){let r=new R({chainID:g(this.config.env)});return new B({config:r})}getController(){let r=this.config.chainApiUrl||i.Chain.ApiUrl(this.config.env),t=new q(r,{timeout:3e4}),e=new x({networkProvider:t});return new I({queryRunner:e})}};var C="xwarp",v=":",y=class{constructor(r){this.config=r;this.config=r}build(r,t){return`${this.config.clientUrl||i.DefaultClientUrl(this.config.env)}?${C}=${encodeURIComponent(r)}${v}${encodeURIComponent(t)}`}async detect(r){let s=new URL(r).searchParams.get(C);if(!s)return{match:!1,warp:null};let[a,o]=s.split(v),h=new l(this.config),W=new f(this.config),p=null;if(a==="hash")p=await h.createFromTransactionHash(o);else if(a==="alias"){let m=await W.resolveAlias(o);m&&(p=await h.createFromTransactionHash(m))}return p?{match:!0,warp:p}:{match:!1,warp:null}}};export{i as Config,l as WarpBuilder,y as WarpLink,f as WarpRegistry};
1
+ var i={ProtocolName:"warp",LatestVersion:"0.1.0",DefaultClientUrl:n=>n==="devnet"?"https://devnet.xwarp.me/to":n==="testnet"?"###Not implemented###":"https://xwarp.me/to",Chain:{ApiUrl:n=>n==="devnet"?"https://devnet-api.multiversx.com":n==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:n=>n==="devnet"?"erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn":n==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"}};import{Address as w,ApiNetworkProvider as q,TransactionsFactoryConfig as T,TransferTransactionsFactory as A}from"@multiversx/sdk-core";var g=n=>n==="devnet"?"D":n==="testnet"?"T":"1",d=()=>`${i.ProtocolName}:${i.LatestVersion}`;var l=class{config;pendingWarp={protocol:d(),name:"",title:"",description:null,preview:"",actions:[]};constructor(r){this.config=r}createInscriptionTransaction(r){if(!this.config.userAddress)throw new Error("warp builder user address not set");let t=new T({chainID:g(this.config.env)}),e=new A({config:t}),s=JSON.stringify(r);return e.createTransactionForNativeTokenTransfer({sender:w.newFromBech32(this.config.userAddress),receiver:w.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Buffer.from(s).valueOf()})}createFromRaw(r){return JSON.parse(r)}createFromTransaction(r){return this.createFromRaw(r.data.toString())}async createFromTransactionHash(r){let t=new q(this.config.chainApiUrl||i.Chain.ApiUrl(this.config.env));try{let e=await t.getTransaction(r);return this.createFromTransaction(e)}catch(e){return console.error("Error creating warp from transaction hash",e),null}}setName(r){return this.pendingWarp.name=r,this}setTitle(r){return this.pendingWarp.title=r,this}setDescription(r){return this.pendingWarp.description=r,this}setPreview(r){return this.pendingWarp.preview=r,this}setActions(r){return this.pendingWarp.actions=r,this}addAction(r){return this.pendingWarp.actions.push(r),this}build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),this.pendingWarp}ensure(r,t){if(!r)throw new Error(`Warp: ${t}`)}};import{Address as u,ApiNetworkProvider as F,BytesValue as c,QueryRunnerAdapter as x,SmartContractQueriesController as I,SmartContractTransactionsFactory as B,TransactionsFactoryConfig as R}from"@multiversx/sdk-core/out";import{byteArrayToHex as P}from"@multiversx/sdk-core/out/utils.codec";var f=class{config;registerCost;constructor(r){this.config=r,this.registerCost=BigInt(0),this.loadRegistryInfo()}createRegisterTransaction(r,t=null){if(this.registerCost===BigInt(0))throw new Error("registry config not loaded");if(!this.config.userAddress)throw new Error("registry config user address not set");let e=t?this.registerCost*BigInt(2):this.registerCost;return this.getFactory().createTransactionForExecute({sender:u.newFromBech32(this.config.userAddress),contract:u.newFromBech32(i.Registry.Contract(this.config.env)),function:"register",gasLimit:BigInt(1e7),nativeTransferAmount:e,arguments:t?[c.fromHex(r),c.fromUTF8(t)]:[c.fromHex(r)]})}createAliasAssignTransaction(r,t){if(!this.config.userAddress)throw new Error("registry config user address not set");return this.getFactory().createTransactionForExecute({sender:u.newFromBech32(this.config.userAddress),contract:u.newFromBech32(i.Registry.Contract(this.config.env)),function:"assignAlias",gasLimit:BigInt(1e7),arguments:[c.fromUTF8(r),c.fromUTF8(t)]})}async resolveAlias(r){let t=i.Registry.Contract(this.config.env),e=this.getController(),s=e.createQuery({contract:t,function:"resolveAlias",arguments:[c.fromUTF8(r)]}),a=await e.runQuery(s);console.log("resolveAlias res",a);let[o]=e.parseQueryResponse(a);return console.log("resolveAlias txHashRaw",o),(o==null?void 0:o.toString())||null}async loadRegistryInfo(){let r=i.Registry.Contract(this.config.env),t=this.getController(),e=t.createQuery({contract:r,function:"getConfig",arguments:[]}),s=await t.runQuery(e),[a]=t.parseQueryResponse(s),o=BigInt("0x"+P(a));this.registerCost=o}getFactory(){let r=new R({chainID:g(this.config.env)});return new B({config:r})}getController(){let r=this.config.chainApiUrl||i.Chain.ApiUrl(this.config.env),t=new F(r,{timeout:3e4}),e=new x({networkProvider:t});return new I({queryRunner:e})}};var C="xwarp",v=":",y=class{constructor(r){this.config=r;this.config=r}build(r,t){return`${this.config.clientUrl||i.DefaultClientUrl(this.config.env)}?${C}=${encodeURIComponent(r)}${v}${encodeURIComponent(t)}`}async detect(r){let s=new URL(r).searchParams.get(C);if(!s)return{match:!1,warp:null};let[a,o]=s.split(v),h=new l(this.config),W=new f(this.config),p=null;if(a==="hash")p=await h.createFromTransactionHash(o);else if(a==="alias"){let m=await W.resolveAlias(o);m&&(p=await h.createFromTransactionHash(m))}return p?{match:!0,warp:p}:{match:!1,warp:null}}};export{i as Config,l as WarpBuilder,y as WarpLink,f as WarpRegistry};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vleap/warps",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",