@vleap/warps 0.0.23 → 0.0.24
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 +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transaction
|
|
2
|
-
import { Transaction as Transaction$1 } from '@multiversx/sdk-core
|
|
1
|
+
import { Transaction } from '@multiversx/sdk-core/out';
|
|
2
|
+
import { Transaction as Transaction$1, TransactionOnNetwork } from '@multiversx/sdk-core';
|
|
3
3
|
|
|
4
4
|
type ChainEnv = 'mainnet' | 'testnet' | 'devnet';
|
|
5
5
|
type WarpConfig = {
|
|
@@ -37,11 +37,14 @@ type WarpLinkAction = {
|
|
|
37
37
|
url: string;
|
|
38
38
|
inputs?: WarpActionInput[];
|
|
39
39
|
};
|
|
40
|
+
type WarpActionInputSource = 'field' | 'query';
|
|
41
|
+
type WarpActionInputType = 'text' | 'number' | 'bigint' | 'boolean' | 'address';
|
|
40
42
|
type WarpActionInput = {
|
|
41
|
-
type: 'query';
|
|
42
43
|
name: string;
|
|
43
|
-
|
|
44
|
+
label?: string;
|
|
45
|
+
type: WarpActionInputType;
|
|
44
46
|
position: string;
|
|
47
|
+
source: WarpActionInputSource;
|
|
45
48
|
};
|
|
46
49
|
type RegistryInfo = {
|
|
47
50
|
alias: string | null;
|
|
@@ -58,13 +61,21 @@ declare const Config: {
|
|
|
58
61
|
Registry: {
|
|
59
62
|
Contract: (env: ChainEnv) => "erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn" | "####" | "erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe";
|
|
60
63
|
};
|
|
64
|
+
AvailableActionInputSources: WarpActionInputSource[];
|
|
65
|
+
AvailableActionInputPositions: string[];
|
|
61
66
|
};
|
|
62
67
|
|
|
68
|
+
declare class WarpActionExecutor {
|
|
69
|
+
private config;
|
|
70
|
+
constructor(config: WarpConfig);
|
|
71
|
+
execute(action: WarpAction): Transaction;
|
|
72
|
+
}
|
|
73
|
+
|
|
63
74
|
declare class WarpBuilder {
|
|
64
75
|
private config;
|
|
65
76
|
private pendingWarp;
|
|
66
77
|
constructor(config: WarpConfig);
|
|
67
|
-
createInscriptionTransaction(warp: Warp): Transaction;
|
|
78
|
+
createInscriptionTransaction(warp: Warp): Transaction$1;
|
|
68
79
|
createFromRaw(encoded: string): Warp;
|
|
69
80
|
createFromTransaction(tx: TransactionOnNetwork): Warp;
|
|
70
81
|
createFromTransactionHash(hash: string): Promise<Warp | null>;
|
|
@@ -94,12 +105,12 @@ declare class WarpRegistry {
|
|
|
94
105
|
private registerCost;
|
|
95
106
|
constructor(config: WarpConfig);
|
|
96
107
|
init(): Promise<void>;
|
|
97
|
-
createRegisterTransaction(txHash: string, registryInfo: RegistryInfo): Transaction
|
|
98
|
-
createAliasAssignTransaction(txHash: string, alias: string): Transaction
|
|
108
|
+
createRegisterTransaction(txHash: string, registryInfo: RegistryInfo): Transaction;
|
|
109
|
+
createAliasAssignTransaction(txHash: string, alias: string): Transaction;
|
|
99
110
|
resolveAlias(alias: string): Promise<string | null>;
|
|
100
111
|
private loadRegistryInfo;
|
|
101
112
|
private getFactory;
|
|
102
113
|
private getController;
|
|
103
114
|
}
|
|
104
115
|
|
|
105
|
-
export { type ChainEnv, Config, type RegistryInfo, type Warp, type WarpAction, type WarpActionInput, type WarpActionType, WarpBuilder, type WarpConfig, type WarpContractAction, type WarpIdType, WarpLink, type WarpLinkAction, WarpRegistry };
|
|
116
|
+
export { type ChainEnv, Config, type RegistryInfo, type Warp, type WarpAction, WarpActionExecutor, type WarpActionInput, type WarpActionInputSource, type WarpActionInputType, type WarpActionType, WarpBuilder, type WarpConfig, type WarpContractAction, type WarpIdType, WarpLink, type WarpLinkAction, WarpRegistry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transaction
|
|
2
|
-
import { Transaction as Transaction$1 } from '@multiversx/sdk-core
|
|
1
|
+
import { Transaction } from '@multiversx/sdk-core/out';
|
|
2
|
+
import { Transaction as Transaction$1, TransactionOnNetwork } from '@multiversx/sdk-core';
|
|
3
3
|
|
|
4
4
|
type ChainEnv = 'mainnet' | 'testnet' | 'devnet';
|
|
5
5
|
type WarpConfig = {
|
|
@@ -37,11 +37,14 @@ type WarpLinkAction = {
|
|
|
37
37
|
url: string;
|
|
38
38
|
inputs?: WarpActionInput[];
|
|
39
39
|
};
|
|
40
|
+
type WarpActionInputSource = 'field' | 'query';
|
|
41
|
+
type WarpActionInputType = 'text' | 'number' | 'bigint' | 'boolean' | 'address';
|
|
40
42
|
type WarpActionInput = {
|
|
41
|
-
type: 'query';
|
|
42
43
|
name: string;
|
|
43
|
-
|
|
44
|
+
label?: string;
|
|
45
|
+
type: WarpActionInputType;
|
|
44
46
|
position: string;
|
|
47
|
+
source: WarpActionInputSource;
|
|
45
48
|
};
|
|
46
49
|
type RegistryInfo = {
|
|
47
50
|
alias: string | null;
|
|
@@ -58,13 +61,21 @@ declare const Config: {
|
|
|
58
61
|
Registry: {
|
|
59
62
|
Contract: (env: ChainEnv) => "erd1qqqqqqqqqqqqqpgq8h85eq9l3cp40h5s3ujqshj2x775m2wyl3tsl20ltn" | "####" | "erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe";
|
|
60
63
|
};
|
|
64
|
+
AvailableActionInputSources: WarpActionInputSource[];
|
|
65
|
+
AvailableActionInputPositions: string[];
|
|
61
66
|
};
|
|
62
67
|
|
|
68
|
+
declare class WarpActionExecutor {
|
|
69
|
+
private config;
|
|
70
|
+
constructor(config: WarpConfig);
|
|
71
|
+
execute(action: WarpAction): Transaction;
|
|
72
|
+
}
|
|
73
|
+
|
|
63
74
|
declare class WarpBuilder {
|
|
64
75
|
private config;
|
|
65
76
|
private pendingWarp;
|
|
66
77
|
constructor(config: WarpConfig);
|
|
67
|
-
createInscriptionTransaction(warp: Warp): Transaction;
|
|
78
|
+
createInscriptionTransaction(warp: Warp): Transaction$1;
|
|
68
79
|
createFromRaw(encoded: string): Warp;
|
|
69
80
|
createFromTransaction(tx: TransactionOnNetwork): Warp;
|
|
70
81
|
createFromTransactionHash(hash: string): Promise<Warp | null>;
|
|
@@ -94,12 +105,12 @@ declare class WarpRegistry {
|
|
|
94
105
|
private registerCost;
|
|
95
106
|
constructor(config: WarpConfig);
|
|
96
107
|
init(): Promise<void>;
|
|
97
|
-
createRegisterTransaction(txHash: string, registryInfo: RegistryInfo): Transaction
|
|
98
|
-
createAliasAssignTransaction(txHash: string, alias: string): Transaction
|
|
108
|
+
createRegisterTransaction(txHash: string, registryInfo: RegistryInfo): Transaction;
|
|
109
|
+
createAliasAssignTransaction(txHash: string, alias: string): Transaction;
|
|
99
110
|
resolveAlias(alias: string): Promise<string | null>;
|
|
100
111
|
private loadRegistryInfo;
|
|
101
112
|
private getFactory;
|
|
102
113
|
private getController;
|
|
103
114
|
}
|
|
104
115
|
|
|
105
|
-
export { type ChainEnv, Config, type RegistryInfo, type Warp, type WarpAction, type WarpActionInput, type WarpActionType, WarpBuilder, type WarpConfig, type WarpContractAction, type WarpIdType, WarpLink, type WarpLinkAction, WarpRegistry };
|
|
116
|
+
export { type ChainEnv, Config, type RegistryInfo, type Warp, type WarpAction, WarpActionExecutor, type WarpActionInput, type WarpActionInputSource, type WarpActionInputType, type WarpActionType, WarpBuilder, type WarpConfig, type WarpContractAction, type WarpIdType, WarpLink, type WarpLinkAction, WarpRegistry };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var I=(n,r)=>{for(var t in r)m(n,t,{get:r[t],enumerable:!0})},P=(n,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of F(r))!x.call(n,o)&&o!==t&&m(n,o,{get:()=>r[o],enumerable:!(i=T(r,o))||i.enumerable});return n};var R=n=>P(m({},"__esModule",{value:!0}),n);var B={};I(B,{Config:()=>s,WarpActionExecutor:()=>h,WarpBuilder:()=>g,WarpLink:()=>d,WarpRegistry:()=>l});module.exports=R(B);var s={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"},AvailableActionInputSources:["field","query"],AvailableActionInputPositions:["value"]};var h=class{constructor(r){this.config=r;this.config=r}execute(r){throw new Error("not implemented")}};var c=require("@multiversx/sdk-core");var f=n=>n==="devnet"?"D":n==="testnet"?"T":"1",v=()=>`${s.ProtocolName}:${s.LatestVersion}`;var g=class{config;pendingWarp={protocol:v(),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 e=require("@multiversx/sdk-core/out"),y=require("@multiversx/sdk-core/out/utils.codec");var l=class{config;registerCost;constructor(r){this.config=r,this.registerCost=BigInt(0)}async init(){await this.loadRegistryInfo()}createRegisterTransaction(r,t){if(this.registerCost===BigInt(0))throw new Error("registry config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("registry config user address not set");let i=t.alias?this.registerCost*BigInt(2):this.registerCost;return this.getFactory().createTransactionForExecute({sender:e.Address.newFromBech32(this.config.userAddress),contract:e.Address.newFromBech32(s.Registry.Contract(this.config.env)),function:"register",gasLimit:BigInt(1e7),nativeTransferAmount:i,arguments:t.alias?[e.BytesValue.fromHex(r),new e.BooleanValue(t.isPublic),e.BytesValue.fromUTF8(t.alias)]:[e.BytesValue.fromHex(r),new e.BooleanValue(t.isPublic)]})}createAliasAssignTransaction(r,t){if(!this.config.userAddress)throw new Error("registry config user address not set");return this.getFactory().createTransactionForExecute({sender:e.Address.newFromBech32(this.config.userAddress),contract:e.Address.newFromBech32(s.Registry.Contract(this.config.env)),function:"assignAlias",gasLimit:BigInt(1e7),arguments:[e.BytesValue.fromUTF8(r),e.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:[e.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,y.byteArrayToHex)(p));this.registerCost=a}getFactory(){let r=new e.TransactionsFactoryConfig({chainID:f(this.config.env)});return new e.SmartContractTransactionsFactory({config:r})}getController(){let r=this.config.chainApiUrl||s.Chain.ApiUrl(this.config.env),t=new e.ApiNetworkProvider(r,{timeout:3e4}),i=new e.QueryRunnerAdapter({networkProvider:t});return new e.SmartContractQueriesController({queryRunner:i})}};var W="xwarp",q=":",d=class{constructor(r){this.config=r;this.config=r}build(r,t){return`${this.config.clientUrl||s.DefaultClientUrl(this.config.env)}?${W}=${encodeURIComponent(r)}${q}${encodeURIComponent(t)}`}async detect(r){let o=new URL(r).searchParams.get(W);if(!o)return{match:!1,warp:null};let[p,a]=o.split(q),w=new g(this.config),A=new l(this.config),u=null;if(p==="hash")u=await w.createFromTransactionHash(a);else if(p==="alias"){let C=await A.resolveAlias(a);C&&(u=await w.createFromTransactionHash(C))}return u?{match:!0,warp:u}:{match:!1,warp:null}}};0&&(module.exports={Config,WarpActionExecutor,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":n==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"}};import{Address as
|
|
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"},AvailableActionInputSources:["field","query"],AvailableActionInputPositions:["value"]};var d=class{constructor(r){this.config=r;this.config=r}execute(r){throw new Error("not implemented")}};import{Address as C,ApiNetworkProvider as T,TransactionsFactoryConfig as F,TransferTransactionsFactory as x}from"@multiversx/sdk-core";var g=n=>n==="devnet"?"D":n==="testnet"?"T":"1",w=()=>`${i.ProtocolName}:${i.LatestVersion}`;var l=class{config;pendingWarp={protocol:w(),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 F({chainID:g(this.config.env)}),e=new x({config:t}),s=JSON.stringify(r);return e.createTransactionForNativeTokenTransfer({sender:C.newFromBech32(this.config.userAddress),receiver:C.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 I,BooleanValue as v,BytesValue as c,QueryRunnerAdapter as P,SmartContractQueriesController as R,SmartContractTransactionsFactory as B,TransactionsFactoryConfig as U}from"@multiversx/sdk-core/out";import{byteArrayToHex as b}from"@multiversx/sdk-core/out/utils.codec";var f=class{config;registerCost;constructor(r){this.config=r,this.registerCost=BigInt(0)}async init(){await this.loadRegistryInfo()}createRegisterTransaction(r,t){if(this.registerCost===BigInt(0))throw new Error("registry config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("registry config user address not set");let e=t.alias?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.alias?[c.fromHex(r),new v(t.isPublic),c.fromUTF8(t.alias)]:[c.fromHex(r),new v(t.isPublic)]})}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"+b(a));this.registerCost=o}getFactory(){let r=new U({chainID:g(this.config.env)});return new B({config:r})}getController(){let r=this.config.chainApiUrl||i.Chain.ApiUrl(this.config.env),t=new I(r,{timeout:3e4}),e=new P({networkProvider:t});return new R({queryRunner:e})}};var y="xwarp",W=":",q=class{constructor(r){this.config=r;this.config=r}build(r,t){return`${this.config.clientUrl||i.DefaultClientUrl(this.config.env)}?${y}=${encodeURIComponent(r)}${W}${encodeURIComponent(t)}`}async detect(r){let s=new URL(r).searchParams.get(y);if(!s)return{match:!1,warp:null};let[a,o]=s.split(W),m=new l(this.config),A=new f(this.config),p=null;if(a==="hash")p=await m.createFromTransactionHash(o);else if(a==="alias"){let h=await A.resolveAlias(o);h&&(p=await m.createFromTransactionHash(h))}return p?{match:!0,warp:p}:{match:!1,warp:null}}};export{i as Config,d as WarpActionExecutor,l as WarpBuilder,q as WarpLink,f as WarpRegistry};
|