@meshsdk/wallet 1.6.0-alpha.20 → 1.6.1
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.cjs +6 -0
- package/dist/index.d.cts +511 -0
- package/dist/index.d.ts +511 -0
- package/dist/index.js +6 -0
- package/package.json +23 -7
- package/jest.config.js +0 -5
- package/src/app/index.ts +0 -239
- package/src/browser/index.ts +0 -440
- package/src/embedded/index.ts +0 -258
- package/src/index.ts +0 -4
- package/src/mesh/index.ts +0 -413
- package/src/types/index.ts +0 -39
- package/test/app.test.ts +0 -98
- package/test/browser.test.ts +0 -21
- package/test/embedded.test.ts +0 -137
- package/test/mesh.test.ts +0 -95
- package/tsconfig.json +0 -5
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var P=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var F=(o,e)=>{for(var t in e)P(o,t,{get:e[t],enumerable:!0})},M=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of z(e))!G.call(o,s)&&s!==t&&P(o,s,{get:()=>e[s],enumerable:!(r=V(e,s))||r.enumerable});return o};var q=o=>M(P({},"__esModule",{value:!0}),o);var te={};F(te,{AppWallet:()=>E,BrowserWallet:()=>C,EmbeddedWallet:()=>p,MeshWallet:()=>B,WalletStaticMethods:()=>y});module.exports=q(te);var A=require("@meshsdk/core-cst");function O(o){if(!Number.isSafeInteger(o))throw new Error(`Wrong integer: ${o}`)}function j(o){return o instanceof Uint8Array||o!=null&&typeof o=="object"&&o.constructor.name==="Uint8Array"}function J(...o){let e=n=>n,t=(n,c)=>d=>n(c(d)),r=o.map(n=>n.encode).reduceRight(t,e),s=o.map(n=>n.decode).reduce(t,e);return{encode:r,decode:s}}function Y(o){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(t=>{if(t<0||t>=o.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${o.length})`);return o[t]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(t=>{if(typeof t!="string")throw new Error(`alphabet.decode: not string element=${t}`);let r=o.indexOf(t);if(r===-1)throw new Error(`Unknown letter: "${t}". Allowed: ${o}`);return r})}}}function Q(o=""){if(typeof o!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let t of e)if(typeof t!="string")throw new Error(`join.encode: non-string input=${t}`);return e.join(o)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(o)}}}var N=(o,e)=>e?N(e,o%e):o,U=(o,e)=>o+(e-N(o,e));function v(o,e,t,r){if(!Array.isArray(o))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(t<=0||t>32)throw new Error(`convertRadix2: wrong to=${t}`);if(U(e,t)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${t} carryBits=${U(e,t)}`);let s=0,n=0,c=2**t-1,d=[];for(let u of o){if(u>=2**e)throw new Error(`convertRadix2: invalid data word=${u} from=${e}`);if(s=s<<e|u,n+e>32)throw new Error(`convertRadix2: carry overflow pos=${n} from=${e}`);for(n+=e;n>=t;n-=t)d.push((s>>n-t&c)>>>0);s&=2**n-1}if(s=s<<t-n&c,!r&&n>=e)throw new Error("Excess padding");if(!r&&s)throw new Error(`Non-zero padding: ${s}`);return r&&n>0&&d.push(s>>>0),d}function X(o,e=!1){if(o<=0||o>32)throw new Error("radix2: bits should be in (0..32]");if(U(8,o)>32||U(o,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!j(t))throw new Error("radix2.encode input should be Uint8Array");return v(Array.from(t),8,o,!e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(v(t,o,8,e))}}}function $(o){if(typeof o!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return o.apply(null,e)}catch{}}}var _=J(Y("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Q("")),D=[996825010,642813549,513874426,1027748829,705979059];function I(o){let e=o>>25,t=(o&33554431)<<5;for(let r=0;r<D.length;r++)(e>>r&1)===1&&(t^=D[r]);return t}function H(o,e,t=1){let r=o.length,s=1;for(let n=0;n<r;n++){let c=o.charCodeAt(n);if(c<33||c>126)throw new Error(`Invalid prefix (${o})`);s=I(s)^c>>5}s=I(s);for(let n=0;n<r;n++)s=I(s)^o.charCodeAt(n)&31;for(let n of e)s=I(s)^n;for(let n=0;n<6;n++)s=I(s);return s^=t,_.encode(v([s%2**30],30,5,!1))}function Z(o){let e=o==="bech32"?1:734539939,t=X(5),r=t.decode,s=t.encode,n=$(r);function c(l,g,h=90){if(typeof l!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof l}`);if(!Array.isArray(g)||g.length&&typeof g[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof g}`);if(l.length===0)throw new TypeError(`Invalid prefix length ${l.length}`);let x=l.length+7+g.length;if(h!==!1&&x>h)throw new TypeError(`Length ${x} exceeds limit ${h}`);let T=l.toLowerCase(),k=H(T,g,e);return`${T}1${_.encode(g)}${k}`}function d(l,g=90){if(typeof l!="string")throw new Error(`bech32.decode input should be string, not ${typeof l}`);if(l.length<8||g!==!1&&l.length>g)throw new TypeError(`Wrong string length: ${l.length} (${l}). Expected (8..${g})`);let h=l.toLowerCase();if(l!==h&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");let x=h.lastIndexOf("1");if(x===0||x===-1)throw new Error('Letter "1" must be present between prefix and data only');let T=h.slice(0,x),k=h.slice(x+1);if(k.length<6)throw new Error("Data must be at least 6 characters long");let W=_.decode(k).slice(0,-6),K=H(T,W,e);if(!k.endsWith(K))throw new Error(`Invalid checksum in ${l}: expected "${K}"`);return{prefix:T,words:W}}let u=$(d);function S(l){let{prefix:g,words:h}=d(l,!1);return{prefix:g,words:h,bytes:r(h)}}return{encode:c,decode:d,decodeToBytes:S,decodeUnsafe:u,fromWords:r,fromWordsUnsafe:n,toWords:s}}var R=Z("bech32");var b=require("@meshsdk/common"),i=require("@meshsdk/core-cst"),y=class{static privateKeyToEntropy(e){let t=R.decodeToBytes(e).bytes,r=i.Bip32PrivateKey.fromBytes(t);return(0,b.bytesToHex)(r.bytes())}static mnemonicToEntropy(e){let t=(0,b.mnemonicToEntropy)(e.join(" ")),r=(0,i.buildBip32PrivateKey)(t);return(0,b.bytesToHex)(r.bytes())}static signingKeyToEntropy(e,t){return[e.startsWith("5820")?e.slice(4):e,t.startsWith("5820")?t.slice(4):t]}static getAddresses(e,t,r=0){let s=(0,i.buildBaseAddress)(r,i.Hash28ByteBase16.fromEd25519KeyHashHex((0,i.Ed25519KeyHashHex)(e.toPublicKey().hash().toString("hex"))),i.Hash28ByteBase16.fromEd25519KeyHashHex((0,i.Ed25519KeyHashHex)(t.toPublicKey().hash().toString("hex")))),n=(0,i.buildEnterpriseAddress)(r,i.Hash28ByteBase16.fromEd25519KeyHashHex((0,i.Ed25519KeyHashHex)(e.toPublicKey().hash().toString("hex")))),c=(0,i.buildRewardAddress)(r,i.Hash28ByteBase16.fromEd25519KeyHashHex((0,i.Ed25519KeyHashHex)(t.toPublicKey().hash().toString("hex"))));return{baseAddress:s.toAddress(),enterpriseAddress:n.toAddress(),rewardAddress:c.toAddress()}}static generateMnemonic(e=256){return(0,b.generateMnemonic)(e).split(" ")}static addWitnessSets(e,t){let r=(0,i.deserializeTx)(e),s=r.witnessSet(),n=s.vkeys(),c=n?[...n.values(),...t]:t;return s.setVkeys(i.Serialization.CborSet.fromCore(c.map(d=>d.toCore()),i.VkeyWitness.fromCore)),new i.Transaction(r.body(),s,r.auxiliaryData()).toCbor()}},p=class extends y{_entropy;_networkId;constructor(e){switch(super(),this._networkId=e.networkId,e.key.type){case"mnemonic":this._entropy=y.mnemonicToEntropy(e.key.words);break;case"root":this._entropy=y.privateKeyToEntropy(e.key.bech32);break;case"cli":this._entropy=y.signingKeyToEntropy(e.key.payment,e.key.stake??"f0".repeat(32));break}}getAccount(e=0,t=0){if(this._entropy==null)throw new Error("[EmbeddedWallet] No keys initialized");let{paymentKey:r,stakeKey:s}=(0,i.buildKeys)(this._entropy,e,t),{baseAddress:n,enterpriseAddress:c,rewardAddress:d}=y.getAddresses(r,s,this._networkId);return{baseAddress:n,enterpriseAddress:c,rewardAddress:d,baseAddressBech32:n.toBech32(),enterpriseAddressBech32:c.toBech32(),rewardAddressBech32:d.toBech32(),paymentKey:r,stakeKey:s,paymentKeyHex:r.toBytes().toString("hex"),stakeKeyHex:s.toBytes().toString("hex")}}getNetworkId(){return this._networkId}signData(e,t,r=0,s=0){try{let n=this.getAccount(r,s);if([n.baseAddress,n.enterpriseAddress,n.rewardAddress].find(d=>d.toBech32()===e)===void 0)throw new Error(`[EmbeddedWallet] Address: ${e} doesn't belong to this account.`);return(0,i.signData)(t,n.paymentKey)}catch(n){throw new Error(`[EmbeddedWallet] An error occurred during signData: ${n}.`)}}signTx(e,t=0,r=0){try{let s=(0,i.deserializeTxHash)((0,i.resolveTxHash)(e)),n=this.getAccount(t,r);return new i.VkeyWitness((0,i.Ed25519PublicKeyHex)(n.paymentKey.toPublicKey().toBytes().toString("hex")),(0,i.Ed25519SignatureHex)(n.paymentKey.sign(Buffer.from(s,"hex")).toString("hex")))}catch(s){throw new Error(`[EmbeddedWallet] An error occurred during signTx: ${s}.`)}}};var E=class{_fetcher;_submitter;_wallet;constructor(e){switch(this._fetcher=e.fetcher,this._submitter=e.submitter,e.key.type){case"mnemonic":this._wallet=new p({networkId:e.networkId,key:{type:"mnemonic",words:e.key.words}});break;case"root":this._wallet=new p({networkId:e.networkId,key:{type:"root",bech32:e.key.bech32}});break;case"cli":this._wallet=new p({networkId:e.networkId,key:{type:"cli",payment:e.key.payment,stake:e.key.stake}})}}async getCollateralUnspentOutput(e=0,t="payment"){let s=(await this.getUnspentOutputs(e,t)).filter(n=>n.output().amount().multiasset()===void 0);s.sort((n,c)=>Number(n.output().amount().coin())-Number(c.output().amount().coin()));for(let n of s)if(Number(n.output().amount().coin())>=5e6)return[n];return[]}getEnterpriseAddress(e=0,t=0){return this._wallet.getAccount(e,t).enterpriseAddressBech32}getPaymentAddress(e=0,t=0){return this._wallet.getAccount(e,t).baseAddressBech32}getRewardAddress(e=0,t=0){return this._wallet.getAccount(e,t).rewardAddressBech32}getNetworkId(){return this._wallet.getNetworkId()}getUsedAddress(e=0,t=0,r="payment"){return r==="enterprise"?(0,A.toAddress)(this.getEnterpriseAddress(e,t)):(0,A.toAddress)(this.getPaymentAddress(e,t))}async getUnspentOutputs(e=0,t="payment"){if(!this._fetcher)throw new Error("[AppWallet] Fetcher is required to fetch UTxOs. Please provide a fetcher.");let r=this._wallet.getAccount(e);return(await this._fetcher.fetchAddressUTxOs(t=="enterprise"?r.enterpriseAddressBech32:r.baseAddressBech32)).map(n=>(0,A.toTxUnspentOutput)(n))}signData(e,t,r=0,s=0){try{return this._wallet.signData(e,t,r,s)}catch(n){throw new Error(`[AppWallet] An error occurred during signData: ${n}.`)}}signTx(e,t=!1,r=0,s=0){try{let n=(0,A.deserializeTx)(e);if(!t&&n.witnessSet().vkeys()!==void 0&&n.witnessSet().vkeys().size()!==0)throw new Error("Signatures already exist in the transaction in a non partial sign call");let c=this._wallet.signTx(e,r,s);return p.addWitnessSets(e,[c])}catch(n){throw new Error(`[AppWallet] An error occurred during signTx: ${n}.`)}}signTxSync(e,t=!1,r=0,s=0){try{return"signedTx"}catch(n){throw new Error(`[AppWallet] An error occurred during signTx: ${n}.`)}}async signTxs(e,t){throw new Error("[AppWallet] signTxs() is not implemented.")}submitTx(e){if(!this._submitter)throw new Error("[AppWallet] Submitter is required to submit transactions. Please provide a submitter.");return this._submitter.submitTx(e)}static brew(e=256){return p.generateMnemonic(e)}};var w=require("@meshsdk/common"),a=require("@meshsdk/core-cst"),C=class o{constructor(e,t){this._walletInstance=e;this._walletName=t;this.walletInstance={...e}}walletInstance;static getInstalledWallets(){if(window===void 0)return[];if(window.cardano===void 0)return[];let e=[];for(let t in window.cardano)try{let r=window.cardano[t];if(r===void 0||r.name===void 0||r.icon===void 0||r.apiVersion===void 0)continue;e.push({id:t,name:r.name,icon:r.icon,version:r.apiVersion})}catch{}return e}static async enable(e){try{let t=await o.resolveInstance(e);if(t!==void 0)return new o(t,e);throw new Error(`Couldn't create an instance of wallet: ${e}`)}catch(t){throw new Error(`[BrowserWallet] An error occurred during enable: ${JSON.stringify(t)}.`)}}async getBalance(){let e=await this._walletInstance.getBalance();return(0,a.fromValue)((0,a.deserializeValue)(e))}async getChangeAddress(){let e=await this._walletInstance.getChangeAddress();return(0,a.addressToBech32)((0,a.deserializeAddress)(e))}async getCollateral(){return(await this.getCollateralUnspentOutput()).map(t=>(0,a.fromTxUnspentOutput)(t))}getNetworkId(){return this._walletInstance.getNetworkId()}async getRewardAddresses(){return(await this._walletInstance.getRewardAddresses()).map(t=>(0,a.addressToBech32)((0,a.deserializeAddress)(t)))}async getUnusedAddresses(){return(await this._walletInstance.getUnusedAddresses()).map(t=>(0,a.addressToBech32)((0,a.deserializeAddress)(t)))}async getUsedAddresses(){return(await this._walletInstance.getUsedAddresses()).map(t=>(0,a.addressToBech32)((0,a.deserializeAddress)(t)))}async getUsedCollateral(e=w.DEFAULT_PROTOCOL_PARAMETERS.maxCollateralInputs){return(await this._walletInstance.experimental.getCollateral()??[]).map(r=>(0,a.deserializeTxUnspentOutput)(r)).slice(0,e)}async getUtxos(){return(await this.getUsedUTxOs()).map(t=>(0,a.fromTxUnspentOutput)(t))}signData(e,t){let r=(0,a.toAddress)(e).toBytes().toString();return this._walletInstance.signData(r,(0,w.fromUTF8)(t))}async signTx(e,t=!1){let r=await this._walletInstance.signTx(e,t);return console.log("witness",r),o.addBrowserWitnesses(e,r)}async signTxs(e,t=!1){let r;switch(this._walletName){case"Typhon Wallet":this._walletInstance.signTxs&&(r=await this._walletInstance.signTxs(e,t));break;default:this._walletInstance.signTxs?r=await this._walletInstance.signTxs(e.map(n=>({cbor:n,partialSign:t}))):this._walletInstance.experimental.signTxs&&(r=await this._walletInstance.experimental.signTxs(e.map(n=>({cbor:n,partialSign:t}))));break}if(!r)throw new Error("Wallet does not support signTxs");let s=[];for(let n=0;n<r.length;n++){let c=e[n],d=r[n],u=o.addBrowserWitnesses(c,d);s.push(u)}return s}submitTx(e){return this._walletInstance.submitTx(e)}async getUsedAddress(){let e=await this._walletInstance.getUsedAddresses();if(e.length===0)throw new Error("No used addresses found");return(0,a.deserializeAddress)(e[0])}async getCollateralUnspentOutput(){return(await this._walletInstance.experimental.getCollateral()??[]).map(t=>(0,a.deserializeTxUnspentOutput)(t))}async getUsedUTxOs(){return(await this._walletInstance.getUtxos()??[]).map(t=>(0,a.deserializeTxUnspentOutput)(t))}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{let r=t.unit.slice(0,w.POLICY_ID_LENGTH),s=t.unit.slice(w.POLICY_ID_LENGTH),n=(0,w.resolveFingerprint)(r,s);return{unit:t.unit,policyId:r,assetName:s,fingerprint:n,quantity:t.quantity}})}async getLovelace(){let t=(await this.getBalance()).find(r=>r.unit==="lovelace");return t!==void 0?t.quantity:"0"}async getPolicyIdAssets(e){return(await this.getAssets()).filter(r=>r.policyId===e)}async getPolicyIds(){let e=await this.getBalance();return Array.from(new Set(e.map(t=>t.unit.slice(0,w.POLICY_ID_LENGTH)))).filter(t=>t!=="lovelace")}static resolveInstance(e){return window.cardano===void 0||window.cardano[e]===void 0?void 0:window.cardano[e]?.enable()}static addBrowserWitnesses(e,t){let r=a.Serialization.TransactionWitnessSet.fromCbor(a.CardanoSDKUtil.HexBlob(t)).vkeys()?.values();if(r===void 0)return e;let s=(0,a.deserializeTx)(e),n=s.witnessSet(),c=n.vkeys(),d=c?[...c.values(),...r]:[...r];return n.setVkeys(a.Serialization.CborSet.fromCore(d.map(u=>u.toCore()),a.VkeyWitness.fromCore)),new a.Transaction(s.body(),n,s.auxiliaryData()).toCbor()}};var f=require("@meshsdk/common"),m=require("@meshsdk/core-cst"),L=require("@meshsdk/transaction");var B=class{_wallet;constructor(e){switch(e.key.type){case"root":this._wallet=new E({networkId:e.networkId,fetcher:e.fetcher,submitter:e.submitter,key:{type:"root",bech32:e.key.bech32}});break;case"cli":this._wallet=new E({networkId:e.networkId,fetcher:e.fetcher,submitter:e.submitter,key:{type:"cli",payment:e.key.payment,stake:e.key.stake}});break;case"mnemonic":this._wallet=new E({networkId:e.networkId,fetcher:e.fetcher,submitter:e.submitter,key:{type:"mnemonic",words:e.key.words}});break}}async getBalance(){let e=await this.getUnspentOutputs(),t=new Map;return e.map(s=>{(0,m.fromTxUnspentOutput)(s).output.amount.map(c=>{let d=c.unit,u=Number(c.quantity);if(t.has(d)){let S=t.get(d);t.set(d,S+u)}else t.set(d,u)})}),Array.from(t,([s,n])=>({unit:s,quantity:n.toString()}))}getChangeAddress(){return this._wallet.getPaymentAddress()}async getCollateral(e="payment"){return(await this._wallet.getCollateralUnspentOutput(0,e)).map((r,s)=>(0,m.fromTxUnspentOutput)(r))}getNetworkId(){return this._wallet.getNetworkId()}getRewardAddresses(){return[this._wallet.getRewardAddress()]}getUnusedAddresses(){return[this.getChangeAddress()]}getUsedAddresses(){return[this.getChangeAddress()]}async getUsedCollateral(){return(await this.getCollateral()).map(r=>(0,m.toTxUnspentOutput)(r))}async getUsedUTxOs(e){return await this.getUnspentOutputs(e)}async getUtxos(e){return(await this.getUsedUTxOs(e)).map(r=>(0,m.fromTxUnspentOutput)(r))}signData(e){return this._wallet.signData(this.getChangeAddress(),e)}signTx(e,t=!1){return this._wallet.signTx(e,t)}signTxs(e,t=!1){let r=[];for(let s of e){let n=this.signTx(s,t);r.push(n)}return r}async submitTx(e){return await this._wallet.submitTx(e)}getUsedAddress(e){return this._wallet.getUsedAddress(0,0,e)}async getUnspentOutputs(e){return await this._wallet.getUnspentOutputs(0,e)}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{let r=t.unit.slice(0,f.POLICY_ID_LENGTH),s=t.unit.slice(f.POLICY_ID_LENGTH),n=(0,f.resolveFingerprint)(r,s);return{unit:t.unit,policyId:r,assetName:(0,f.toUTF8)(s),fingerprint:n,quantity:t.quantity}})}async getLovelace(){let t=(await this.getBalance()).find(r=>r.unit==="lovelace");return t!==void 0?t.quantity:"0"}async getPolicyIdAssets(e){return(await this.getAssets()).filter(r=>r.policyId===e)}async getPolicyIds(){let e=await this.getBalance();return Array.from(new Set(e.map(t=>t.unit.slice(0,f.POLICY_ID_LENGTH)))).filter(t=>t!=="lovelace")}async createCollateral(){let e=new L.Transaction({initiator:this});e.sendLovelace(this.getChangeAddress(),"5000000");let t=await e.build(),r=await this.signTx(t);return await this.submitTx(r)}static brew(e=!1,t=256){let r=p.generateMnemonic(t);return e?(0,m.resolvePrivateKey)(r):r}};0&&(module.exports={AppWallet,BrowserWallet,EmbeddedWallet,MeshWallet,WalletStaticMethods});
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
@scure/base/lib/esm/index.js:
|
|
5
|
+
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
6
|
+
*/
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import { DataSignature, IFetcher, ISubmitter, ISigner, IInitiator, Wallet, Asset, UTxO, AssetExtended } from '@meshsdk/common';
|
|
2
|
+
import { TransactionUnspentOutput, Address, PrivateKey, VkeyWitness } from '@meshsdk/core-cst';
|
|
3
|
+
|
|
4
|
+
type Cardano = {
|
|
5
|
+
[key: string]: {
|
|
6
|
+
name: string;
|
|
7
|
+
icon: string;
|
|
8
|
+
apiVersion: string;
|
|
9
|
+
enable: () => Promise<WalletInstance>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type TransactionSignatureRequest = {
|
|
13
|
+
cbor: string;
|
|
14
|
+
partialSign: boolean;
|
|
15
|
+
};
|
|
16
|
+
type WalletInstance = {
|
|
17
|
+
experimental: ExperimentalFeatures;
|
|
18
|
+
getBalance(): Promise<string>;
|
|
19
|
+
getChangeAddress(): Promise<string>;
|
|
20
|
+
getNetworkId(): Promise<number>;
|
|
21
|
+
getRewardAddresses(): Promise<string[]>;
|
|
22
|
+
getUnusedAddresses(): Promise<string[]>;
|
|
23
|
+
getUsedAddresses(): Promise<string[]>;
|
|
24
|
+
getUtxos(): Promise<string[] | undefined>;
|
|
25
|
+
signData(address: string, payload: string): Promise<DataSignature>;
|
|
26
|
+
signTx(tx: string, partialSign: boolean): Promise<string>;
|
|
27
|
+
signTxs?(txs: TransactionSignatureRequest[]): Promise<string[]>;
|
|
28
|
+
signTxs?(txs: string[], partialSign: boolean): Promise<string[]>;
|
|
29
|
+
submitTx(tx: string): Promise<string>;
|
|
30
|
+
};
|
|
31
|
+
type ExperimentalFeatures = {
|
|
32
|
+
getCollateral(): Promise<string[] | undefined>;
|
|
33
|
+
signTxs?(txs: TransactionSignatureRequest[]): Promise<string[]>;
|
|
34
|
+
signTxs?(txs: string[], partialSign: boolean): Promise<string[]>;
|
|
35
|
+
};
|
|
36
|
+
type GetAddressType = "enterprise" | "payment";
|
|
37
|
+
|
|
38
|
+
type AppWalletKeyType = {
|
|
39
|
+
type: "root";
|
|
40
|
+
bech32: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: "cli";
|
|
43
|
+
payment: string;
|
|
44
|
+
stake?: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: "mnemonic";
|
|
47
|
+
words: string[];
|
|
48
|
+
};
|
|
49
|
+
type CreateAppWalletOptions = {
|
|
50
|
+
networkId: number;
|
|
51
|
+
fetcher?: IFetcher;
|
|
52
|
+
submitter?: ISubmitter;
|
|
53
|
+
key: AppWalletKeyType;
|
|
54
|
+
};
|
|
55
|
+
declare class AppWallet implements ISigner, ISubmitter {
|
|
56
|
+
private readonly _fetcher?;
|
|
57
|
+
private readonly _submitter?;
|
|
58
|
+
private readonly _wallet;
|
|
59
|
+
constructor(options: CreateAppWalletOptions);
|
|
60
|
+
/**
|
|
61
|
+
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
62
|
+
*
|
|
63
|
+
* This is used in transaction building.
|
|
64
|
+
*
|
|
65
|
+
* @returns a list of UTXOs
|
|
66
|
+
*/
|
|
67
|
+
getCollateralUnspentOutput(accountIndex?: number, addressType?: GetAddressType): Promise<TransactionUnspentOutput[]>;
|
|
68
|
+
getEnterpriseAddress(accountIndex?: number, keyIndex?: number): string;
|
|
69
|
+
getPaymentAddress(accountIndex?: number, keyIndex?: number): string;
|
|
70
|
+
getRewardAddress(accountIndex?: number, keyIndex?: number): string;
|
|
71
|
+
getNetworkId(): number;
|
|
72
|
+
getUsedAddress(accountIndex?: number, keyIndex?: number, addressType?: GetAddressType): Address;
|
|
73
|
+
getUnspentOutputs(accountIndex?: number, addressType?: GetAddressType): Promise<TransactionUnspentOutput[]>;
|
|
74
|
+
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): DataSignature;
|
|
75
|
+
signTx(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): string;
|
|
76
|
+
signTxSync(unsignedTx: string, partialSign?: boolean, accountIndex?: number, keyIndex?: number): string;
|
|
77
|
+
signTxs(unsignedTxs: string[], partialSign: boolean): Promise<string[]>;
|
|
78
|
+
submitTx(tx: string): Promise<string>;
|
|
79
|
+
static brew(strength?: number): string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare global {
|
|
83
|
+
interface Window {
|
|
84
|
+
cardano: Cardano;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
declare class BrowserWallet implements IInitiator, ISigner, ISubmitter {
|
|
88
|
+
readonly _walletInstance: WalletInstance;
|
|
89
|
+
readonly _walletName: string;
|
|
90
|
+
walletInstance: WalletInstance;
|
|
91
|
+
private constructor();
|
|
92
|
+
/**
|
|
93
|
+
* Returns a list of wallets installed on user's device. Each wallet is an object with the following properties:
|
|
94
|
+
* - A name is provided to display wallet's name on the user interface.
|
|
95
|
+
* - A version is provided to display wallet's version on the user interface.
|
|
96
|
+
* - An icon is provided to display wallet's icon on the user interface.
|
|
97
|
+
*
|
|
98
|
+
* @returns a list of wallet names
|
|
99
|
+
*/
|
|
100
|
+
static getInstalledWallets(): Wallet[];
|
|
101
|
+
/**
|
|
102
|
+
* This is the entrypoint to start communication with the user's wallet. The wallet should request the user's permission to connect the web page to the user's wallet, and if permission has been granted, the wallet will be returned and exposing the full API for the dApp to use.
|
|
103
|
+
*
|
|
104
|
+
* Query BrowserWallet.getInstalledWallets() to get a list of available wallets, then provide the wallet name for which wallet the user would like to connect with.
|
|
105
|
+
*
|
|
106
|
+
* @param walletName
|
|
107
|
+
* @returns WalletInstance
|
|
108
|
+
*/
|
|
109
|
+
static enable(walletName: string): Promise<BrowserWallet>;
|
|
110
|
+
/**
|
|
111
|
+
* Retrieves the total available balance of the wallet, encoded in CBOR.
|
|
112
|
+
* @returns {Promise<Value>} - The balance of the wallet.
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
|
|
116
|
+
* - A unit is provided to display asset's name on the user interface.
|
|
117
|
+
* - A quantity is provided to display asset's quantity on the user interface.
|
|
118
|
+
*
|
|
119
|
+
* @returns a list of assets and their quantities
|
|
120
|
+
*/
|
|
121
|
+
getBalance(): Promise<Asset[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Returns an address owned by the wallet that should be used as a change address to return leftover assets during transaction creation back to the connected wallet.
|
|
124
|
+
*
|
|
125
|
+
* @returns an address
|
|
126
|
+
*/
|
|
127
|
+
getChangeAddress(): Promise<string>;
|
|
128
|
+
/**
|
|
129
|
+
* This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
|
|
130
|
+
*
|
|
131
|
+
* If this cannot be attained, an error message with an explanation of the blocking problem shall be returned. NOTE: wallets are free to return UTXOs that add up to a greater total ADA value than requested in the amount parameter, but wallets must never return any result where UTXOs would sum up to a smaller total ADA value, instead in a case like that an error message must be returned.
|
|
132
|
+
*
|
|
133
|
+
* @param limit
|
|
134
|
+
* @returns a list of UTXOs
|
|
135
|
+
*/
|
|
136
|
+
getCollateral(): Promise<UTxO[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Returns the network ID of the currently connected account. 0 is testnet and 1 is mainnet but other networks can possibly be returned by wallets. Those other network ID values are not governed by CIP-30. This result will stay the same unless the connected account has changed.
|
|
139
|
+
*
|
|
140
|
+
* @returns network ID
|
|
141
|
+
*/
|
|
142
|
+
getNetworkId(): Promise<number>;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a list of reward addresses owned by the wallet. A reward address is a stake address that is used to receive rewards from staking, generally starts from `stake` prefix.
|
|
145
|
+
*
|
|
146
|
+
* @returns a list of reward addresses
|
|
147
|
+
*/
|
|
148
|
+
getRewardAddresses(): Promise<string[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Returns a list of unused addresses controlled by the wallet.
|
|
151
|
+
*
|
|
152
|
+
* @returns a list of unused addresses
|
|
153
|
+
*/
|
|
154
|
+
getUnusedAddresses(): Promise<string[]>;
|
|
155
|
+
/**
|
|
156
|
+
* Returns a list of used addresses controlled by the wallet.
|
|
157
|
+
*
|
|
158
|
+
* @returns a list of used addresses
|
|
159
|
+
*/
|
|
160
|
+
getUsedAddresses(): Promise<string[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
163
|
+
*
|
|
164
|
+
* This is used in transaction building.
|
|
165
|
+
*
|
|
166
|
+
* @returns a list of UTXOs
|
|
167
|
+
*/
|
|
168
|
+
getUsedCollateral(limit?: number): Promise<TransactionUnspentOutput[]>;
|
|
169
|
+
/**
|
|
170
|
+
* Return a list of all UTXOs (unspent transaction outputs) controlled by the wallet.
|
|
171
|
+
*
|
|
172
|
+
* @returns a list of UTXOs
|
|
173
|
+
*/
|
|
174
|
+
getUtxos(): Promise<UTxO[]>;
|
|
175
|
+
/**
|
|
176
|
+
* This endpoint utilizes the [CIP-8 - Message Signing](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) to sign arbitrary data, to verify the data was signed by the owner of the private key.
|
|
177
|
+
*
|
|
178
|
+
* Here, we get the first wallet's address with wallet.getUsedAddresses(), alternativelly you can use reward addresses (getRewardAddresses()) too. It's really up to you as the developer which address you want to use in your application.
|
|
179
|
+
*
|
|
180
|
+
* @param address
|
|
181
|
+
* @param payload
|
|
182
|
+
* @returns a signature
|
|
183
|
+
*/
|
|
184
|
+
signData(address: string, payload: string): Promise<DataSignature>;
|
|
185
|
+
/**
|
|
186
|
+
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
187
|
+
*
|
|
188
|
+
* @param unsignedTx
|
|
189
|
+
* @param partialSign
|
|
190
|
+
* @returns a signed transaction in CBOR
|
|
191
|
+
*/
|
|
192
|
+
signTx(unsignedTx: string, partialSign?: boolean): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Experimental feature - sign multiple transactions at once (Supported wallet(s): Typhon)
|
|
195
|
+
*
|
|
196
|
+
* @param unsignedTxs - array of unsigned transactions in CborHex string
|
|
197
|
+
* @param partialSign - if the transactions are signed partially
|
|
198
|
+
* @returns array of signed transactions CborHex string
|
|
199
|
+
*/
|
|
200
|
+
signTxs(unsignedTxs: string[], partialSign?: boolean): Promise<string[]>;
|
|
201
|
+
/**
|
|
202
|
+
* Submits the signed transaction to the blockchain network.
|
|
203
|
+
*
|
|
204
|
+
* As wallets should already have this ability to submit transaction, we allow dApps to request that a transaction be sent through it. If the wallet accepts the transaction and tries to send it, it shall return the transaction ID for the dApp to track. The wallet can return error messages or failure if there was an error in sending it.
|
|
205
|
+
*
|
|
206
|
+
* @param tx
|
|
207
|
+
* @returns a transaction hash
|
|
208
|
+
*/
|
|
209
|
+
submitTx(tx: string): Promise<string>;
|
|
210
|
+
/**
|
|
211
|
+
* Get a used address of type Address from the wallet.
|
|
212
|
+
*
|
|
213
|
+
* This is used in transaction building.
|
|
214
|
+
*
|
|
215
|
+
* @returns an Address object
|
|
216
|
+
*/
|
|
217
|
+
getUsedAddress(): Promise<Address>;
|
|
218
|
+
/**
|
|
219
|
+
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
220
|
+
*
|
|
221
|
+
* This is used in transaction building.
|
|
222
|
+
*
|
|
223
|
+
* @returns a list of UTXOs
|
|
224
|
+
*/
|
|
225
|
+
getCollateralUnspentOutput(): Promise<TransactionUnspentOutput[]>;
|
|
226
|
+
/**
|
|
227
|
+
* Get a list of UTXOs to be used for transaction building.
|
|
228
|
+
*
|
|
229
|
+
* This is used in transaction building.
|
|
230
|
+
*
|
|
231
|
+
* @returns a list of UTXOs
|
|
232
|
+
*/
|
|
233
|
+
getUsedUTxOs(): Promise<TransactionUnspentOutput[]>;
|
|
234
|
+
/**
|
|
235
|
+
* A helper function to get the assets in the wallet.
|
|
236
|
+
*
|
|
237
|
+
* @returns a list of assets
|
|
238
|
+
*/
|
|
239
|
+
getAssets(): Promise<AssetExtended[]>;
|
|
240
|
+
/**
|
|
241
|
+
* A helper function to get the lovelace balance in the wallet.
|
|
242
|
+
*
|
|
243
|
+
* @returns lovelace balance
|
|
244
|
+
*/
|
|
245
|
+
getLovelace(): Promise<string>;
|
|
246
|
+
/**
|
|
247
|
+
* A helper function to get the assets of a specific policy ID in the wallet.
|
|
248
|
+
*
|
|
249
|
+
* @param policyId
|
|
250
|
+
* @returns a list of assets
|
|
251
|
+
*/
|
|
252
|
+
getPolicyIdAssets(policyId: string): Promise<AssetExtended[]>;
|
|
253
|
+
/**
|
|
254
|
+
* A helper function to get the policy IDs of all the assets in the wallet.
|
|
255
|
+
*
|
|
256
|
+
* @returns a list of policy IDs
|
|
257
|
+
*/
|
|
258
|
+
getPolicyIds(): Promise<string[]>;
|
|
259
|
+
private static resolveInstance;
|
|
260
|
+
static addBrowserWitnesses(unsignedTx: string, witnesses: string): string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
type Account = {
|
|
264
|
+
baseAddress: Address;
|
|
265
|
+
enterpriseAddress: Address;
|
|
266
|
+
rewardAddress: Address;
|
|
267
|
+
baseAddressBech32: string;
|
|
268
|
+
enterpriseAddressBech32: string;
|
|
269
|
+
rewardAddressBech32: string;
|
|
270
|
+
paymentKey: PrivateKey;
|
|
271
|
+
stakeKey: PrivateKey;
|
|
272
|
+
paymentKeyHex: string;
|
|
273
|
+
stakeKeyHex: string;
|
|
274
|
+
};
|
|
275
|
+
type EmbeddedWalletKeyType = {
|
|
276
|
+
type: "root";
|
|
277
|
+
bech32: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: "cli";
|
|
280
|
+
payment: string;
|
|
281
|
+
stake?: string;
|
|
282
|
+
} | {
|
|
283
|
+
type: "mnemonic";
|
|
284
|
+
words: string[];
|
|
285
|
+
};
|
|
286
|
+
type CreateEmbeddedWalletOptions = {
|
|
287
|
+
networkId: number;
|
|
288
|
+
key: EmbeddedWalletKeyType;
|
|
289
|
+
};
|
|
290
|
+
declare class WalletStaticMethods {
|
|
291
|
+
static privateKeyToEntropy(bech32: string): string;
|
|
292
|
+
static mnemonicToEntropy(words: string[]): string;
|
|
293
|
+
static signingKeyToEntropy(paymentKey: string, stakeKey: string): [string, string];
|
|
294
|
+
static getAddresses(paymentKey: PrivateKey, stakingKey: PrivateKey, networkId?: number): {
|
|
295
|
+
baseAddress: Address;
|
|
296
|
+
enterpriseAddress: Address;
|
|
297
|
+
rewardAddress: Address;
|
|
298
|
+
};
|
|
299
|
+
static generateMnemonic(strength?: number): string[];
|
|
300
|
+
static addWitnessSets(txHex: string, witnesses: VkeyWitness[]): string;
|
|
301
|
+
}
|
|
302
|
+
declare class EmbeddedWallet extends WalletStaticMethods {
|
|
303
|
+
private readonly _entropy?;
|
|
304
|
+
private readonly _networkId;
|
|
305
|
+
constructor(options: CreateEmbeddedWalletOptions);
|
|
306
|
+
getAccount(accountIndex?: number, keyIndex?: number): Account;
|
|
307
|
+
getNetworkId(): number;
|
|
308
|
+
signData(address: string, payload: string, accountIndex?: number, keyIndex?: number): DataSignature;
|
|
309
|
+
signTx(unsignedTx: string, accountIndex?: number, keyIndex?: number): VkeyWitness;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
type CreateMeshWalletOptions = {
|
|
313
|
+
networkId: number;
|
|
314
|
+
fetcher?: IFetcher;
|
|
315
|
+
submitter?: ISubmitter;
|
|
316
|
+
key: {
|
|
317
|
+
type: "root";
|
|
318
|
+
bech32: string;
|
|
319
|
+
} | {
|
|
320
|
+
type: "cli";
|
|
321
|
+
payment: string;
|
|
322
|
+
stake?: string;
|
|
323
|
+
} | {
|
|
324
|
+
type: "mnemonic";
|
|
325
|
+
words: string[];
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Mesh Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
|
|
330
|
+
*
|
|
331
|
+
* It is a single address wallet, a wrapper around the AppWallet class.
|
|
332
|
+
*
|
|
333
|
+
* ```javascript
|
|
334
|
+
* import { MeshWallet, BlockfrostProvider } from '@meshsdksdk/core';
|
|
335
|
+
*
|
|
336
|
+
* const blockchainProvider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
|
|
337
|
+
*
|
|
338
|
+
* const wallet = new MeshWallet({
|
|
339
|
+
* networkId: 0,
|
|
340
|
+
* fetcher: blockchainProvider,
|
|
341
|
+
* submitter: blockchainProvider,
|
|
342
|
+
* key: {
|
|
343
|
+
* type: 'mnemonic',
|
|
344
|
+
* words: ["solution","solution","solution","solution","solution",","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
|
|
345
|
+
* },
|
|
346
|
+
* });
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare class MeshWallet implements IInitiator, ISigner, ISubmitter {
|
|
350
|
+
private readonly _wallet;
|
|
351
|
+
constructor(options: CreateMeshWalletOptions);
|
|
352
|
+
/**
|
|
353
|
+
* Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
|
|
354
|
+
* - A unit is provided to display asset's name on the user interface.
|
|
355
|
+
* - A quantity is provided to display asset's quantity on the user interface.
|
|
356
|
+
*
|
|
357
|
+
* @returns a list of assets and their quantities
|
|
358
|
+
*/
|
|
359
|
+
getBalance(): Promise<Asset[]>;
|
|
360
|
+
/**
|
|
361
|
+
* Returns an address owned by the wallet that should be used as a change address to return leftover assets during transaction creation back to the connected wallet.
|
|
362
|
+
*
|
|
363
|
+
* @returns an address
|
|
364
|
+
*/
|
|
365
|
+
getChangeAddress(): string;
|
|
366
|
+
/**
|
|
367
|
+
* This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
|
|
368
|
+
*
|
|
369
|
+
* If this cannot be attained, an error message with an explanation of the blocking problem shall be returned. NOTE: wallets are free to return UTXOs that add up to a greater total ADA value than requested in the amount parameter, but wallets must never return any result where UTXOs would sum up to a smaller total ADA value, instead in a case like that an error message must be returned.
|
|
370
|
+
*
|
|
371
|
+
* @returns a list of UTXOs
|
|
372
|
+
*/
|
|
373
|
+
getCollateral(addressType?: GetAddressType): Promise<UTxO[]>;
|
|
374
|
+
/**
|
|
375
|
+
* Returns the network ID of the currently connected account. 0 is testnet and 1 is mainnet but other networks can possibly be returned by wallets. Those other network ID values are not governed by CIP-30. This result will stay the same unless the connected account has changed.
|
|
376
|
+
*
|
|
377
|
+
* @returns network ID
|
|
378
|
+
*/
|
|
379
|
+
getNetworkId(): number;
|
|
380
|
+
/**
|
|
381
|
+
* Returns a list of reward addresses owned by the wallet. A reward address is a stake address that is used to receive rewards from staking, generally starts from `stake` prefix.
|
|
382
|
+
*
|
|
383
|
+
* @returns a list of reward addresses
|
|
384
|
+
*/
|
|
385
|
+
getRewardAddresses(): string[];
|
|
386
|
+
/**
|
|
387
|
+
* Returns a list of unused addresses controlled by the wallet.
|
|
388
|
+
*
|
|
389
|
+
* @returns a list of unused addresses
|
|
390
|
+
*/
|
|
391
|
+
getUnusedAddresses(): string[];
|
|
392
|
+
/**
|
|
393
|
+
* Returns a list of used addresses controlled by the wallet.
|
|
394
|
+
*
|
|
395
|
+
* @returns a list of used addresses
|
|
396
|
+
*/
|
|
397
|
+
getUsedAddresses(): string[];
|
|
398
|
+
/**
|
|
399
|
+
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
|
|
400
|
+
*
|
|
401
|
+
* This is used in transaction building.
|
|
402
|
+
*
|
|
403
|
+
* @returns a list of UTXOs
|
|
404
|
+
*/
|
|
405
|
+
getUsedCollateral(): Promise<TransactionUnspentOutput[]>;
|
|
406
|
+
/**
|
|
407
|
+
* Get a list of UTXOs to be used for transaction building.
|
|
408
|
+
*
|
|
409
|
+
* This is used in transaction building.
|
|
410
|
+
*
|
|
411
|
+
* @returns a list of UTXOs
|
|
412
|
+
*/
|
|
413
|
+
getUsedUTxOs(addressType?: GetAddressType): Promise<TransactionUnspentOutput[]>;
|
|
414
|
+
/**
|
|
415
|
+
* Return a list of all UTXOs (unspent transaction outputs) controlled by the wallet.
|
|
416
|
+
*
|
|
417
|
+
* @returns a list of UTXOs
|
|
418
|
+
*/
|
|
419
|
+
getUtxos(addressType?: GetAddressType): Promise<UTxO[]>;
|
|
420
|
+
/**
|
|
421
|
+
* This endpoint utilizes the [CIP-8 - Message Signing](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) to sign arbitrary data, to verify the data was signed by the owner of the private key.
|
|
422
|
+
*
|
|
423
|
+
* Here, we get the first wallet's address with wallet.getUsedAddresses(), alternativelly you can use reward addresses (getRewardAddresses()) too. It's really up to you as the developer which address you want to use in your application.
|
|
424
|
+
*
|
|
425
|
+
* @param address
|
|
426
|
+
* @param payload
|
|
427
|
+
* @returns a signature
|
|
428
|
+
*/
|
|
429
|
+
signData(payload: string): DataSignature;
|
|
430
|
+
/**
|
|
431
|
+
* Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
|
|
432
|
+
*
|
|
433
|
+
* @param unsignedTx
|
|
434
|
+
* @param partialSign
|
|
435
|
+
* @returns a signed transaction in CBOR
|
|
436
|
+
*/
|
|
437
|
+
signTx(unsignedTx: string, partialSign?: boolean): string;
|
|
438
|
+
/**
|
|
439
|
+
* Experimental feature - sign multiple transactions at once.
|
|
440
|
+
*
|
|
441
|
+
* @param unsignedTxs - array of unsigned transactions in CborHex string
|
|
442
|
+
* @param partialSign - if the transactions are signed partially
|
|
443
|
+
* @returns array of signed transactions CborHex string
|
|
444
|
+
*/
|
|
445
|
+
signTxs(unsignedTxs: string[], partialSign?: boolean): string[];
|
|
446
|
+
/**
|
|
447
|
+
* Submits the signed transaction to the blockchain network.
|
|
448
|
+
*
|
|
449
|
+
* As wallets should already have this ability to submit transaction, we allow dApps to request that a transaction be sent through it. If the wallet accepts the transaction and tries to send it, it shall return the transaction ID for the dApp to track. The wallet can return error messages or failure if there was an error in sending it.
|
|
450
|
+
*
|
|
451
|
+
* @param tx
|
|
452
|
+
* @returns a transaction hash
|
|
453
|
+
*/
|
|
454
|
+
submitTx(tx: string): Promise<string>;
|
|
455
|
+
/**
|
|
456
|
+
* Get a used address of type Address from the wallet.
|
|
457
|
+
*
|
|
458
|
+
* This is used in transaction building.
|
|
459
|
+
*
|
|
460
|
+
* @returns an Address object
|
|
461
|
+
*/
|
|
462
|
+
getUsedAddress(addressType?: GetAddressType): Address;
|
|
463
|
+
/**
|
|
464
|
+
* Get a list of UTXOs to be used for transaction building.
|
|
465
|
+
*
|
|
466
|
+
* This is used in transaction building.
|
|
467
|
+
*
|
|
468
|
+
* @returns a list of UTXOs
|
|
469
|
+
*/
|
|
470
|
+
getUnspentOutputs(addressType?: GetAddressType): Promise<TransactionUnspentOutput[]>;
|
|
471
|
+
/**
|
|
472
|
+
* A helper function to get the assets in the wallet.
|
|
473
|
+
*
|
|
474
|
+
* @returns a list of assets
|
|
475
|
+
*/
|
|
476
|
+
getAssets(): Promise<AssetExtended[]>;
|
|
477
|
+
/**
|
|
478
|
+
* A helper function to get the lovelace balance in the wallet.
|
|
479
|
+
*
|
|
480
|
+
* @returns lovelace balance
|
|
481
|
+
*/
|
|
482
|
+
getLovelace(): Promise<string>;
|
|
483
|
+
/**
|
|
484
|
+
* A helper function to get the assets of a specific policy ID in the wallet.
|
|
485
|
+
*
|
|
486
|
+
* @param policyId
|
|
487
|
+
* @returns a list of assets
|
|
488
|
+
*/
|
|
489
|
+
getPolicyIdAssets(policyId: string): Promise<AssetExtended[]>;
|
|
490
|
+
/**
|
|
491
|
+
* A helper function to get the policy IDs of all the assets in the wallet.
|
|
492
|
+
*
|
|
493
|
+
* @returns a list of policy IDs
|
|
494
|
+
*/
|
|
495
|
+
getPolicyIds(): Promise<string[]>;
|
|
496
|
+
/**
|
|
497
|
+
* A helper function to create a collateral input for a transaction.
|
|
498
|
+
*
|
|
499
|
+
* @returns a transaction hash
|
|
500
|
+
*/
|
|
501
|
+
createCollateral(): Promise<string>;
|
|
502
|
+
/**
|
|
503
|
+
* Generate mnemonic or private key
|
|
504
|
+
*
|
|
505
|
+
* @param privateKey return private key if true
|
|
506
|
+
* @returns a transaction hash
|
|
507
|
+
*/
|
|
508
|
+
static brew(privateKey?: boolean, strength?: number): string[] | string;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export { type Account, AppWallet, type AppWalletKeyType, BrowserWallet, type CreateAppWalletOptions, type CreateEmbeddedWalletOptions, type CreateMeshWalletOptions, EmbeddedWallet, type EmbeddedWalletKeyType, MeshWallet, WalletStaticMethods };
|