@aptos-labs/wallet-standard
Advanced tools
Comparing version 0.0.13 to 0.1.0
import { WalletAccount, WalletWithFeatures, IdentifierRecord, Wallet, WalletsEventsListeners } from '@wallet-standard/core'; | ||
export * from '@wallet-standard/core'; | ||
import { SigningScheme, AccountAddressInput, PublicKey, Serializable, AccountAddress, Serializer, Deserializer, Network, AnyRawTransaction, PendingTransactionResponse, Signature, AccountAuthenticator } from '@aptos-labs/ts-sdk'; | ||
import { SigningScheme, AccountAddressInput, PublicKey, Serializable, AccountAddress, Serializer, Deserializer, Network, InputGenerateTransactionPayloadData, Signature, AnyRawTransaction, AccountAuthenticator } from '@aptos-labs/ts-sdk'; | ||
@@ -55,3 +55,3 @@ interface AptosWalletAccount extends WalletAccount { | ||
/** Version of the feature. */ | ||
type AptosSignAndSubmitTransactionVersion = '1.0.0'; | ||
type AptosSignAndSubmitTransactionVersion = '1.1.0'; | ||
/** Name of the feature. */ | ||
@@ -72,5 +72,10 @@ declare const AptosSignAndSubmitTransactionNamespace = "aptos:signAndSubmitTransaction"; | ||
type AptosSignAndSubmitTransactionMethod = (transaction: AptosSignAndSubmitTransactionInput) => Promise<UserResponse<AptosSignAndSubmitTransactionOutput>>; | ||
type AptosSignAndSubmitTransactionInput = AnyRawTransaction; | ||
/** Output of signing transactions. */ | ||
type AptosSignAndSubmitTransactionOutput = PendingTransactionResponse; | ||
interface AptosSignAndSubmitTransactionInput { | ||
gasUnitPrice?: number; | ||
maxGasAmount?: number; | ||
payload: InputGenerateTransactionPayloadData; | ||
} | ||
interface AptosSignAndSubmitTransactionOutput { | ||
hash: string; | ||
} | ||
@@ -77,0 +82,0 @@ /** Version of the feature. */ |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _core = require('@wallet-standard/core'); _createStarExport(_core);var _tssdk = require('@aptos-labs/ts-sdk');var l=class n extends _tssdk.Serializable{constructor({address:e,publicKey:t,ansName:s}){super();this.address=_tssdk.AccountAddress.from(e),this.publicKey=t,this.ansName=s}serialize(e){if(this.address.serialize(e),this.publicKey instanceof _tssdk.Ed25519PublicKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.Ed25519);else if(this.publicKey instanceof _tssdk.MultiEd25519PublicKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.MultiEd25519);else if(this.publicKey instanceof _tssdk.AnyPublicKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.SingleKey);else if(this.publicKey instanceof _tssdk.MultiKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.MultiKey);else throw new Error("Unsupported public key");this.publicKey.serialize(e),e.serializeStr(_nullishCoalesce(this.ansName, () => ("")))}static deserialize(e){let t=_tssdk.AccountAddress.deserialize(e),s=e.deserializeUleb128AsU32(),r;switch(s){case _tssdk.SigningScheme.Ed25519:r=_tssdk.Ed25519PublicKey.deserialize(e);break;case _tssdk.SigningScheme.MultiEd25519:r=_tssdk.MultiEd25519PublicKey.deserialize(e);break;case _tssdk.SigningScheme.SingleKey:r=_tssdk.AnyPublicKey.deserialize(e);break;case _tssdk.SigningScheme.MultiKey:r=_tssdk.MultiKey.deserialize(e);break;default:throw new Error(`Unknown variant index for WrappedPublicKey: ${s}`)}let d=e.deserializeStr()||void 0;return new n({address:t,publicKey:r,ansName:d})}};var y="aptos:devnet",x= exports.APTOS_TESTNET_CHAIN ="aptos:testnet",f= exports.APTOS_LOCALNET_CHAIN ="aptos:localnet",N= exports.APTOS_MAINNET_CHAIN ="aptos:mainnet",R= exports.APTOS_CHAINS =[y,x,f,N];var w=["aptos:account","aptos:connect","aptos:disconnect","aptos:network","aptos:onAccountChange","aptos:onNetworkChange","aptos:signMessage","aptos:signTransaction"];function k(n,p=[]){return[...w,...p].every(e=>e in n.features)}function G(){let{get:n,on:p}=_core.getWallets.call(void 0, ),e=n(),t=[];return e.map(s=>{k(s)&&t.push(s)}),{aptosWallets:t,on:p}}var b=(e=>(e[e.Unauthorized=4100]="Unauthorized",e[e.InternalError=-30001]="InternalError",e))(b||{}),m= exports.AptosWalletErrors =Object.freeze({4100:{status:"Unauthorized",message:"The requested method and/or account has not been authorized by the user."},[-30001]:{status:"Internal error",message:"Something went wrong within the wallet."}}),g= exports.AptosWalletError =class n extends Error{constructor(e,t){super(_nullishCoalesce(_nullishCoalesce(t, () => (_optionalChain([m, 'access', _2 => _2[e], 'optionalAccess', _3 => _3.message]))), () => ("Unknown error occurred")));this.code=e,this.status=_nullishCoalesce(_optionalChain([m, 'access', _4 => _4[e], 'optionalAccess', _5 => _5.status]), () => ("Unknown error")),this.name="AptosWalletError",Object.setPrototypeOf(this,n.prototype)}};var _="aptos:signAndSubmitTransaction";var H="aptos:signMessage";var L="aptos:account";var $="aptos:connect";var Q="aptos:network";var X="aptos:onAccountChange";var Z="aptos:onNetworkChange";var te="aptos:changeNetwork";var ne="aptos:disconnect";var re="aptos:signTransaction";var ae="aptos:openInMobileApp";var C=(e=>(e.APPROVED="Approved",e.REJECTED="Rejected",e))(C||{});exports.APTOS_CHAINS = R; exports.APTOS_DEVNET_CHAIN = y; exports.APTOS_LOCALNET_CHAIN = f; exports.APTOS_MAINNET_CHAIN = N; exports.APTOS_TESTNET_CHAIN = x; exports.AccountInfo = l; exports.AptosChangeNetworkNamespace = te; exports.AptosConnectNamespace = $; exports.AptosDisconnectNamespace = ne; exports.AptosGetAccountNamespace = L; exports.AptosGetNetworkNamespace = Q; exports.AptosOnAccountChangeNamespace = X; exports.AptosOnNetworkChangeNamespace = Z; exports.AptosOpenInMobileAppNamespace = ae; exports.AptosSignAndSubmitTransactionNamespace = _; exports.AptosSignMessageNamespace = H; exports.AptosSignTransactionNamespace = re; exports.AptosWalletError = g; exports.AptosWalletErrorCode = b; exports.AptosWalletErrors = m; exports.UserResponseStatus = C; exports.getAptosWallets = G; exports.isWalletWithRequiredFeatureSet = k; | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _core = require('@wallet-standard/core'); _createStarExport(_core);var _tssdk = require('@aptos-labs/ts-sdk');var m=class n extends _tssdk.Serializable{constructor({address:e,publicKey:t,ansName:s}){super();this.address=_tssdk.AccountAddress.from(e),this.publicKey=t,this.ansName=s}serialize(e){if(this.address.serialize(e),this.publicKey instanceof _tssdk.Ed25519PublicKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.Ed25519);else if(this.publicKey instanceof _tssdk.MultiEd25519PublicKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.MultiEd25519);else if(this.publicKey instanceof _tssdk.AnyPublicKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.SingleKey);else if(this.publicKey instanceof _tssdk.MultiKey)e.serializeU32AsUleb128(_tssdk.SigningScheme.MultiKey);else throw new Error("Unsupported public key");this.publicKey.serialize(e),e.serializeStr(_nullishCoalesce(this.ansName, () => ("")))}static deserialize(e){let t=_tssdk.AccountAddress.deserialize(e),s=e.deserializeUleb128AsU32(),r;switch(s){case _tssdk.SigningScheme.Ed25519:r=_tssdk.Ed25519PublicKey.deserialize(e);break;case _tssdk.SigningScheme.MultiEd25519:r=_tssdk.MultiEd25519PublicKey.deserialize(e);break;case _tssdk.SigningScheme.SingleKey:r=_tssdk.AnyPublicKey.deserialize(e);break;case _tssdk.SigningScheme.MultiKey:r=_tssdk.MultiKey.deserialize(e);break;default:throw new Error(`Unknown variant index for WrappedPublicKey: ${s}`)}let d=e.deserializeStr()||void 0;return new n({address:t,publicKey:r,ansName:d})}};var x="aptos:devnet",f= exports.APTOS_TESTNET_CHAIN ="aptos:testnet",y= exports.APTOS_LOCALNET_CHAIN ="aptos:localnet",N= exports.APTOS_MAINNET_CHAIN ="aptos:mainnet",P= exports.APTOS_CHAINS =[x,f,y,N];var w=["aptos:account","aptos:connect","aptos:disconnect","aptos:network","aptos:onAccountChange","aptos:onNetworkChange","aptos:signMessage","aptos:signTransaction"];function b(n,p=[]){return[...w,...p].every(e=>e in n.features)}function G(){let{get:n,on:p}=_core.getWallets.call(void 0, ),e=n(),t=[];return e.map(s=>{b(s)&&t.push(s)}),{aptosWallets:t,on:p}}var k=(e=>(e[e.Unauthorized=4100]="Unauthorized",e[e.InternalError=-30001]="InternalError",e))(k||{}),l= exports.AptosWalletErrors =Object.freeze({4100:{status:"Unauthorized",message:"The requested method and/or account has not been authorized by the user."},[-30001]:{status:"Internal error",message:"Something went wrong within the wallet."}}),g= exports.AptosWalletError =class n extends Error{constructor(e,t){super(_nullishCoalesce(_nullishCoalesce(t, () => (_optionalChain([l, 'access', _2 => _2[e], 'optionalAccess', _3 => _3.message]))), () => ("Unknown error occurred")));this.code=e,this.status=_nullishCoalesce(_optionalChain([l, 'access', _4 => _4[e], 'optionalAccess', _5 => _5.status]), () => ("Unknown error")),this.name="AptosWalletError",Object.setPrototypeOf(this,n.prototype)}};var _="aptos:signAndSubmitTransaction";var H="aptos:signMessage";var L="aptos:account";var $="aptos:connect";var Q="aptos:network";var X="aptos:onAccountChange";var Z="aptos:onNetworkChange";var te="aptos:changeNetwork";var ne="aptos:disconnect";var re="aptos:signTransaction";var ae="aptos:openInMobileApp";var C=(e=>(e.APPROVED="Approved",e.REJECTED="Rejected",e))(C||{});exports.APTOS_CHAINS = P; exports.APTOS_DEVNET_CHAIN = x; exports.APTOS_LOCALNET_CHAIN = y; exports.APTOS_MAINNET_CHAIN = N; exports.APTOS_TESTNET_CHAIN = f; exports.AccountInfo = m; exports.AptosChangeNetworkNamespace = te; exports.AptosConnectNamespace = $; exports.AptosDisconnectNamespace = ne; exports.AptosGetAccountNamespace = L; exports.AptosGetNetworkNamespace = Q; exports.AptosOnAccountChangeNamespace = X; exports.AptosOnNetworkChangeNamespace = Z; exports.AptosOpenInMobileAppNamespace = ae; exports.AptosSignAndSubmitTransactionNamespace = _; exports.AptosSignMessageNamespace = H; exports.AptosSignTransactionNamespace = re; exports.AptosWalletError = g; exports.AptosWalletErrorCode = k; exports.AptosWalletErrors = l; exports.UserResponseStatus = C; exports.getAptosWallets = G; exports.isWalletWithRequiredFeatureSet = b; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@aptos-labs/wallet-standard", | ||
"description": "Aptos wallet standard", | ||
"version": "0.0.13", | ||
"version": "0.1.0", | ||
"license": "Apache-2.0", | ||
@@ -44,3 +44,3 @@ "homepage": "https://github.com/aptos-labs/wallet-standard", | ||
"peerDependencies": { | ||
"@aptos-labs/ts-sdk": "^1.16.0", | ||
"@aptos-labs/ts-sdk": "^1.17.0", | ||
"@wallet-standard/core": "^1.0.3" | ||
@@ -47,0 +47,0 @@ }, |
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { AnyRawTransaction, PendingTransactionResponse } from '@aptos-labs/ts-sdk' | ||
import { InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk' | ||
import { UserResponse } from '../misc' | ||
/** Version of the feature. */ | ||
export type AptosSignAndSubmitTransactionVersion = '1.0.0' | ||
export type AptosSignAndSubmitTransactionVersion = '1.1.0' | ||
/** Name of the feature. */ | ||
@@ -27,4 +28,10 @@ export const AptosSignAndSubmitTransactionNamespace = 'aptos:signAndSubmitTransaction' | ||
export type AptosSignAndSubmitTransactionInput = AnyRawTransaction | ||
/** Output of signing transactions. */ | ||
export type AptosSignAndSubmitTransactionOutput = PendingTransactionResponse | ||
export interface AptosSignAndSubmitTransactionInput { | ||
gasUnitPrice?: number; // defaults to estimated gas unit price | ||
maxGasAmount?: number; // defaults to estimated max gas amount | ||
payload: InputGenerateTransactionPayloadData; | ||
} | ||
export interface AptosSignAndSubmitTransactionOutput { | ||
hash: string; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
121848
871