@vectis/extension-client
Advanced tools
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| }); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getVectisForCosmos = exports.isInstalled = exports.VectisCosmosProvider = void 0; | ||
| const cosmos_provider_1 = require("./providers/cosmos.provider"); | ||
| Object.defineProperty(exports, "VectisCosmosProvider", { enumerable: true, get: function () { return cosmos_provider_1.VectisCosmosProvider; } }); | ||
| __exportStar(require("./types"), exports); | ||
| function isInstalled() { | ||
| return !!window.vectis; | ||
| } | ||
| exports.isInstalled = isInstalled; | ||
| function getVectisForCosmos() { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| if (isInstalled()) | ||
| return new cosmos_provider_1.VectisCosmosProvider(); | ||
| if (document.readyState === 'complete') { | ||
| if (isInstalled()) | ||
| return new cosmos_provider_1.VectisCosmosProvider(); | ||
| else | ||
| throw new Error('Vectis is not installed'); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| const documentStateChange = (event) => { | ||
| if (event.target && event.target.readyState === 'complete') { | ||
| if (isInstalled()) | ||
| resolve(new cosmos_provider_1.VectisCosmosProvider()); | ||
| else | ||
| reject(new Error('Vectis is not installed')); | ||
| } | ||
| document.removeEventListener('readystatechange', documentStateChange); | ||
| }; | ||
| document.addEventListener('readystatechange', documentStateChange); | ||
| }); | ||
| }); | ||
| } | ||
| exports.getVectisForCosmos = getVectisForCosmos; |
| "use strict"; | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| }); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.VectisCosmosProvider = void 0; | ||
| class VectisCosmosProvider { | ||
| getClient() { | ||
| var _a; | ||
| if ((_a = window.vectis) === null || _a === void 0 ? void 0 : _a.cosmos) | ||
| return window.vectis.cosmos; | ||
| throw new Error('Vectis is not installed'); | ||
| } | ||
| enable(chainIds) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| yield this.getClient().enable(chainIds); | ||
| }); | ||
| } | ||
| getKey(chainId) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| return yield this.getClient().getKey(chainId); | ||
| }); | ||
| } | ||
| getAccount(chainId) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| return yield this.getClient().getAccounts(chainId); | ||
| }); | ||
| } | ||
| getSupportedChains() { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| return yield this.getClient().getSupportedChains(); | ||
| }); | ||
| } | ||
| suggestChains(chainsInfo) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| yield this.getClient().suggestChains(chainsInfo); | ||
| }); | ||
| } | ||
| isChainSupported(chainId) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| const supportedChains = yield this.getClient().getSupportedChains(); | ||
| return supportedChains.some((c) => c.chainId === chainId); | ||
| }); | ||
| } | ||
| signAmino(signerAddress, doc) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| return yield this.getClient().signAmino(signerAddress, doc); | ||
| }); | ||
| } | ||
| signDirect(signerAddress, doc) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| return yield this.getClient().signDirect(signerAddress, doc); | ||
| }); | ||
| } | ||
| getOfflineSignerAuto(chainId) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| return yield this.getClient().getOfflineSignerAuto(chainId); | ||
| }); | ||
| } | ||
| getOfflineSignerAmino(chainId) { | ||
| return this.getClient().getOfflineSignerAmino(chainId); | ||
| } | ||
| getOfflineSignerDirect(chainId) { | ||
| return this.getClient().getOfflineSignerDirect(chainId); | ||
| } | ||
| getOfflineSigner(chainId) { | ||
| return this.getClient().getOfflineSigner(chainId); | ||
| } | ||
| onAccountChange(handler) { | ||
| window.addEventListener('vectis_accountChanged', handler); | ||
| } | ||
| offAccountChange(handler) { | ||
| window.removeEventListener('vectis_accountChanged', handler); | ||
| } | ||
| } | ||
| exports.VectisCosmosProvider = VectisCosmosProvider; |
| "use strict"; | ||
| /** | ||
| * Types in this file belongs to cosmjs library https://github.com/cosmos/cosmjs and https://github.com/confio/cosmjs-types | ||
| * We extract them in order to reduce the size of the bundle. | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { VectisCosmosProvider } from './providers/cosmos.provider'; | ||
| export { VectisCosmosProvider }; | ||
| export * from './types'; | ||
| export declare function isInstalled(): boolean; | ||
| export declare function getVectisForCosmos(): Promise<VectisCosmosProvider>; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,cAAc,SAAS,CAAC;AAExB,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAkBxE"} |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./cosmos"), exports); | ||
| __exportStar(require("./vectis"), exports); |
| import { AccountData, AminoSignResponse, DirectSignResponse, OfflineSigner, OfflineAminoSigner, OfflineDirectSigner, SignDoc, StdSignDoc } from '../types/cosmos'; | ||
| import { ChainInfo, KeyInfo, CosmosProvider } from '../types'; | ||
| export declare class VectisCosmosProvider { | ||
| getClient(): CosmosProvider; | ||
| enable(chainIds: string | string[]): Promise<void>; | ||
| getKey(chainId: string): Promise<KeyInfo>; | ||
| getAccount(chainId: string): Promise<AccountData[]>; | ||
| getSupportedChains(): Promise<ChainInfo[]>; | ||
| suggestChains(chainsInfo: ChainInfo[]): Promise<void>; | ||
| isChainSupported(chainId: string): Promise<boolean>; | ||
| signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>; | ||
| signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>; | ||
| getOfflineSignerAuto(chainId: string): Promise<OfflineSigner>; | ||
| getOfflineSignerAmino(chainId: string): OfflineAminoSigner; | ||
| getOfflineSignerDirect(chainId: string): OfflineDirectSigner; | ||
| getOfflineSigner(chainId: string): OfflineSigner; | ||
| onAccountChange(handler: EventListener): void; | ||
| offAccountChange(handler: EventListener): void; | ||
| } | ||
| //# sourceMappingURL=cosmos.provider.d.ts.map |
| {"version":3,"file":"cosmos.provider.d.ts","sourceRoot":"","sources":["../../../../src/providers/cosmos.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,OAAO,EACP,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE9D,qBAAa,oBAAoB;IAC/B,SAAS,IAAI,cAAc;IAKrB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAInD,kBAAkB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAI1C,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnD,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI7E,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI5E,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAInE,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB;IAI1D,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB;IAI5D,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;IAIhD,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAI7C,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;CAG/C"} |
| /** | ||
| * Types in this file belongs to cosmjs library https://github.com/cosmos/cosmjs and https://github.com/confio/cosmjs-types | ||
| * We extract them in order to reduce the size of the bundle. | ||
| */ | ||
| /// <reference types="long" /> | ||
| export interface AccountData { | ||
| /** A printable address (typically bech32 encoded) */ | ||
| readonly address: string; | ||
| readonly algo: Algo; | ||
| readonly pubkey: Uint8Array; | ||
| } | ||
| export interface Pubkey { | ||
| readonly type: string; | ||
| readonly value: any; | ||
| } | ||
| export declare type Algo = 'secp256k1' | 'ed25519' | 'sr25519'; | ||
| export interface Coin { | ||
| readonly denom: string; | ||
| readonly amount: string; | ||
| } | ||
| export interface StdFee { | ||
| readonly amount: readonly Coin[]; | ||
| readonly gas: string; | ||
| } | ||
| export interface StdSignDoc { | ||
| readonly chain_id: string; | ||
| readonly account_number: string; | ||
| readonly sequence: string; | ||
| readonly fee: StdFee; | ||
| readonly msgs: readonly AminoMsg[]; | ||
| readonly memo: string; | ||
| } | ||
| export interface AminoMsg { | ||
| readonly type: string; | ||
| readonly value: any; | ||
| } | ||
| export interface AminoSignResponse { | ||
| /** | ||
| * The sign doc that was signed. | ||
| * This may be different from the input signDoc when the signer modifies it as part of the signing process. | ||
| */ | ||
| readonly signed: StdSignDoc; | ||
| readonly signature: StdSignature; | ||
| } | ||
| export interface DirectSignResponse { | ||
| /** | ||
| * The sign doc that was signed. | ||
| * This may be different from the input signDoc when the signer modifies it as part of the signing process. | ||
| */ | ||
| readonly signed: SignDoc; | ||
| readonly signature: StdSignature; | ||
| } | ||
| export interface StdSignature { | ||
| readonly pub_key: Pubkey; | ||
| readonly signature: string; | ||
| } | ||
| export interface SignDoc { | ||
| /** | ||
| * body_bytes is protobuf serialization of a TxBody that matches the | ||
| * representation in TxRaw. | ||
| */ | ||
| bodyBytes: Uint8Array; | ||
| /** | ||
| * auth_info_bytes is a protobuf serialization of an AuthInfo that matches the | ||
| * representation in TxRaw. | ||
| */ | ||
| authInfoBytes: Uint8Array; | ||
| /** | ||
| * chain_id is the unique identifier of the chain this transaction targets. | ||
| * It prevents signed transactions from being used on another chain by an | ||
| * attacker | ||
| */ | ||
| chainId: string; | ||
| /** account_number is the account number of the account in state */ | ||
| accountNumber: Long; | ||
| } | ||
| export interface OfflineDirectSigner { | ||
| readonly getAccounts: () => Promise<readonly AccountData[]>; | ||
| readonly signDirect: (signerAddress: string, signDoc: SignDoc) => Promise<DirectSignResponse>; | ||
| } | ||
| export interface OfflineAminoSigner { | ||
| /** | ||
| * Get AccountData array from wallet. Rejects if not enabled. | ||
| */ | ||
| readonly getAccounts: () => Promise<readonly AccountData[]>; | ||
| /** | ||
| * Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled. | ||
| * | ||
| * The signer implementation may offer the user the ability to override parts of the signDoc. It must | ||
| * return the doc that was signed in the response. | ||
| * | ||
| * @param signerAddress The address of the account that should sign the transaction | ||
| * @param signDoc The content that should be signed | ||
| */ | ||
| readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>; | ||
| } | ||
| export declare type OfflineSigner = OfflineAminoSigner | OfflineDirectSigner; | ||
| //# sourceMappingURL=cosmos.d.ts.map |
| {"version":3,"file":"cosmos.d.ts","sourceRoot":"","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AM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,SAAS,EAAE,UAAU,CAAC;IACtB;;;OAGG;IACH,aAAa,EAAE,UAAU,CAAC;IAC1B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,aAAa,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC;IAC5D,QAAQ,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC/F;AAED,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC;IAC5D;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAChG;AAED,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG,kBAAkB,GAAG,mBAAmB,CAAC"} |
| export * from './cosmos'; | ||
| export * from './vectis'; | ||
| export type { VectisWindow } from './window'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"} |
| import { AccountData, AminoSignResponse, DirectSignResponse, OfflineAminoSigner, OfflineDirectSigner, OfflineSigner, SignDoc, StdSignDoc } from './cosmos'; | ||
| type Algo = 'secp256k1' | 'ethsecp256k1'; | ||
| export interface KeyInfo { | ||
| algo: Algo; | ||
| name: string; | ||
| pubKey: Uint8Array; | ||
| address: string; | ||
| isNanoLedger: boolean; | ||
| isVectisAccount: boolean; | ||
| } | ||
| export interface CosmosProvider { | ||
| suggestChains(chainsInfo: ChainInfo[]): Promise<void>; | ||
| enable(chainIds: string | string[]): Promise<void>; | ||
| getSupportedChains(): Promise<ChainInfo[]>; | ||
| getKey(chainId: string): Promise<KeyInfo>; | ||
| getAccounts(chainId: string): Promise<AccountData[]>; | ||
| signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>; | ||
| signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>; | ||
| getOfflineSignerAmino(chainId: string): OfflineAminoSigner; | ||
| getOfflineSignerDirect(chainId: string): OfflineDirectSigner; | ||
| getOfflineSigner(chainId: string): OfflineSigner; | ||
| /** | ||
| * Detect what signer should use based on the key type | ||
| * Ex: Nano ledger only supports amino signing. | ||
| */ | ||
| getOfflineSignerAuto(chainId: string): Promise<OfflineSigner>; | ||
| } | ||
| export interface ChainInfo { | ||
| readonly rpcUrl: string; | ||
| readonly restUrl: string; | ||
| readonly chainId: string; | ||
| readonly chainName: string; | ||
| readonly prettyName: string; | ||
| readonly bech32Prefix: string; | ||
| readonly bip44: { | ||
| readonly coinType: number; | ||
| }; | ||
| readonly currencies: AppCurrency[]; | ||
| readonly stakeCurrency: Currency; | ||
| readonly feeCurrencies: FeeCurrency[]; | ||
| readonly features?: string[]; | ||
| readonly isSuggested?: boolean; | ||
| readonly ecosystem?: string; | ||
| } | ||
| export interface Currency { | ||
| readonly coinDenom: string; | ||
| readonly coinMinimalDenom: string; | ||
| readonly coinDecimals: number; | ||
| readonly coinGeckoId?: string; | ||
| readonly coinImageUrl?: string; | ||
| } | ||
| export interface CW20Currency extends Currency { | ||
| readonly type: 'cw20'; | ||
| readonly contractAddress: string; | ||
| } | ||
| export interface IBCCurrency extends Currency { | ||
| readonly paths: { | ||
| portId: string; | ||
| channelId: string; | ||
| }[]; | ||
| readonly originChainId: string | undefined; | ||
| readonly originCurrency: Currency | CW20Currency | undefined; | ||
| } | ||
| export type AppCurrency = Currency | CW20Currency | IBCCurrency; | ||
| export type FeeCurrency = WithGasPriceStep<AppCurrency>; | ||
| export type WithGasPriceStep<T> = T & { | ||
| readonly gasPriceStep?: { | ||
| readonly low: number; | ||
| readonly average: number; | ||
| readonly high: number; | ||
| }; | ||
| }; | ||
| export {}; | ||
| //# sourceMappingURL=vectis.d.ts.map |
| {"version":3,"file":"vectis.d.ts","sourceRoot":"","sources":["../../../../src/types/vectis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,KAAK,IAAI,GAAG,WAAW,GAAG,cAAc,CAAC;AACzC,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,kBAAkB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3C,MAAM,CAAC,OAAO,EAAE,MAA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,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AACD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,KAAK,EAAE;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;IACJ,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,cAAc,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC;CAC9D;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,WAAW,CAAC;AAEhE,MAAM,MAAM,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;AAExD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG;IACpC,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC"} |
| import { CosmosProvider } from './vectis'; | ||
| export interface VectisWindow { | ||
| vectis: { | ||
| cosmos: CosmosProvider; | ||
| version: string; | ||
| }; | ||
| } | ||
| //# sourceMappingURL=window.d.ts.map |
| {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../../../src/types/window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QACN,MAAM,EAAE,cAAc,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { VectisCosmosProvider } from './providers/cosmos.provider'; | ||
| export { VectisCosmosProvider }; | ||
| export * from './types'; | ||
| export function isInstalled() { | ||
| return !!window.vectis; | ||
| } | ||
| export async function getVectisForCosmos() { | ||
| if (isInstalled()) | ||
| return new VectisCosmosProvider(); | ||
| if (document.readyState === 'complete') { | ||
| if (isInstalled()) | ||
| return new VectisCosmosProvider(); | ||
| else | ||
| throw new Error('Vectis is not installed'); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| const documentStateChange = (event) => { | ||
| if (event.target && event.target.readyState === 'complete') { | ||
| if (isInstalled()) | ||
| resolve(new VectisCosmosProvider()); | ||
| else | ||
| reject(new Error('Vectis is not installed')); | ||
| } | ||
| document.removeEventListener('readystatechange', documentStateChange); | ||
| }; | ||
| document.addEventListener('readystatechange', documentStateChange); | ||
| }); | ||
| } |
| export class VectisCosmosProvider { | ||
| getClient() { | ||
| if (window.vectis?.cosmos) | ||
| return window.vectis.cosmos; | ||
| throw new Error('Vectis is not installed'); | ||
| } | ||
| async enable(chainIds) { | ||
| await this.getClient().enable(chainIds); | ||
| } | ||
| async getKey(chainId) { | ||
| return await this.getClient().getKey(chainId); | ||
| } | ||
| async getAccount(chainId) { | ||
| return await this.getClient().getAccounts(chainId); | ||
| } | ||
| async getSupportedChains() { | ||
| return await this.getClient().getSupportedChains(); | ||
| } | ||
| async suggestChains(chainsInfo) { | ||
| await this.getClient().suggestChains(chainsInfo); | ||
| } | ||
| async isChainSupported(chainId) { | ||
| const supportedChains = await this.getClient().getSupportedChains(); | ||
| return supportedChains.some((c) => c.chainId === chainId); | ||
| } | ||
| async signAmino(signerAddress, doc) { | ||
| return await this.getClient().signAmino(signerAddress, doc); | ||
| } | ||
| async signDirect(signerAddress, doc) { | ||
| return await this.getClient().signDirect(signerAddress, doc); | ||
| } | ||
| async getOfflineSignerAuto(chainId) { | ||
| return await this.getClient().getOfflineSignerAuto(chainId); | ||
| } | ||
| getOfflineSignerAmino(chainId) { | ||
| return this.getClient().getOfflineSignerAmino(chainId); | ||
| } | ||
| getOfflineSignerDirect(chainId) { | ||
| return this.getClient().getOfflineSignerDirect(chainId); | ||
| } | ||
| getOfflineSigner(chainId) { | ||
| return this.getClient().getOfflineSigner(chainId); | ||
| } | ||
| onAccountChange(handler) { | ||
| window.addEventListener('vectis_accountChanged', handler); | ||
| } | ||
| offAccountChange(handler) { | ||
| window.removeEventListener('vectis_accountChanged', handler); | ||
| } | ||
| } |
| /** | ||
| * Types in this file belongs to cosmjs library https://github.com/cosmos/cosmjs and https://github.com/confio/cosmjs-types | ||
| * We extract them in order to reduce the size of the bundle. | ||
| */ | ||
| export {}; |
| import { VectisCosmosProvider } from './providers/cosmos.provider'; | ||
| export { VectisCosmosProvider }; | ||
| export * from './types'; | ||
| export declare function isInstalled(): boolean; | ||
| export declare function getVectisForCosmos(): Promise<VectisCosmosProvider>; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,cAAc,SAAS,CAAC;AAExB,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAkBxE"} |
| export * from './cosmos'; | ||
| export * from './vectis'; |
| import { AccountData, AminoSignResponse, DirectSignResponse, OfflineSigner, OfflineAminoSigner, OfflineDirectSigner, SignDoc, StdSignDoc } from '../types/cosmos'; | ||
| import { ChainInfo, KeyInfo, CosmosProvider } from '../types'; | ||
| export declare class VectisCosmosProvider { | ||
| getClient(): CosmosProvider; | ||
| enable(chainIds: string | string[]): Promise<void>; | ||
| getKey(chainId: string): Promise<KeyInfo>; | ||
| getAccount(chainId: string): Promise<AccountData[]>; | ||
| getSupportedChains(): Promise<ChainInfo[]>; | ||
| suggestChains(chainsInfo: ChainInfo[]): Promise<void>; | ||
| isChainSupported(chainId: string): Promise<boolean>; | ||
| signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>; | ||
| signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>; | ||
| getOfflineSignerAuto(chainId: string): Promise<OfflineSigner>; | ||
| getOfflineSignerAmino(chainId: string): OfflineAminoSigner; | ||
| getOfflineSignerDirect(chainId: string): OfflineDirectSigner; | ||
| getOfflineSigner(chainId: string): OfflineSigner; | ||
| onAccountChange(handler: EventListener): void; | ||
| offAccountChange(handler: EventListener): void; | ||
| } | ||
| //# sourceMappingURL=cosmos.provider.d.ts.map |
| {"version":3,"file":"cosmos.provider.d.ts","sourceRoot":"","sources":["../../../../src/providers/cosmos.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,OAAO,EACP,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE9D,qBAAa,oBAAoB;IAC/B,SAAS,IAAI,cAAc;IAKrB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAInD,kBAAkB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAI1C,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnD,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI7E,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI5E,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAInE,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB;IAI1D,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB;IAI5D,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;IAIhD,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAI7C,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;CAG/C"} |
| /** | ||
| * Types in this file belongs to cosmjs library https://github.com/cosmos/cosmjs and https://github.com/confio/cosmjs-types | ||
| * We extract them in order to reduce the size of the bundle. | ||
| */ | ||
| /// <reference types="long" /> | ||
| export interface AccountData { | ||
| /** A printable address (typically bech32 encoded) */ | ||
| readonly address: string; | ||
| readonly algo: Algo; | ||
| readonly pubkey: Uint8Array; | ||
| } | ||
| export interface Pubkey { | ||
| readonly type: string; | ||
| readonly value: any; | ||
| } | ||
| export declare type Algo = 'secp256k1' | 'ed25519' | 'sr25519'; | ||
| export interface Coin { | ||
| readonly denom: string; | ||
| readonly amount: string; | ||
| } | ||
| export interface StdFee { | ||
| readonly amount: readonly Coin[]; | ||
| readonly gas: string; | ||
| } | ||
| export interface StdSignDoc { | ||
| readonly chain_id: string; | ||
| readonly account_number: string; | ||
| readonly sequence: string; | ||
| readonly fee: StdFee; | ||
| readonly msgs: readonly AminoMsg[]; | ||
| readonly memo: string; | ||
| } | ||
| export interface AminoMsg { | ||
| readonly type: string; | ||
| readonly value: any; | ||
| } | ||
| export interface AminoSignResponse { | ||
| /** | ||
| * The sign doc that was signed. | ||
| * This may be different from the input signDoc when the signer modifies it as part of the signing process. | ||
| */ | ||
| readonly signed: StdSignDoc; | ||
| readonly signature: StdSignature; | ||
| } | ||
| export interface DirectSignResponse { | ||
| /** | ||
| * The sign doc that was signed. | ||
| * This may be different from the input signDoc when the signer modifies it as part of the signing process. | ||
| */ | ||
| readonly signed: SignDoc; | ||
| readonly signature: StdSignature; | ||
| } | ||
| export interface StdSignature { | ||
| readonly pub_key: Pubkey; | ||
| readonly signature: string; | ||
| } | ||
| export interface SignDoc { | ||
| /** | ||
| * body_bytes is protobuf serialization of a TxBody that matches the | ||
| * representation in TxRaw. | ||
| */ | ||
| bodyBytes: Uint8Array; | ||
| /** | ||
| * auth_info_bytes is a protobuf serialization of an AuthInfo that matches the | ||
| * representation in TxRaw. | ||
| */ | ||
| authInfoBytes: Uint8Array; | ||
| /** | ||
| * chain_id is the unique identifier of the chain this transaction targets. | ||
| * It prevents signed transactions from being used on another chain by an | ||
| * attacker | ||
| */ | ||
| chainId: string; | ||
| /** account_number is the account number of the account in state */ | ||
| accountNumber: Long; | ||
| } | ||
| export interface OfflineDirectSigner { | ||
| readonly getAccounts: () => Promise<readonly AccountData[]>; | ||
| readonly signDirect: (signerAddress: string, signDoc: SignDoc) => Promise<DirectSignResponse>; | ||
| } | ||
| export interface OfflineAminoSigner { | ||
| /** | ||
| * Get AccountData array from wallet. Rejects if not enabled. | ||
| */ | ||
| readonly getAccounts: () => Promise<readonly AccountData[]>; | ||
| /** | ||
| * Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled. | ||
| * | ||
| * The signer implementation may offer the user the ability to override parts of the signDoc. It must | ||
| * return the doc that was signed in the response. | ||
| * | ||
| * @param signerAddress The address of the account that should sign the transaction | ||
| * @param signDoc The content that should be signed | ||
| */ | ||
| readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>; | ||
| } | ||
| export declare type OfflineSigner = OfflineAminoSigner | OfflineDirectSigner; | ||
| //# sourceMappingURL=cosmos.d.ts.map |
| {"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../../../../src/types/cosmos.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,MAAM,IAAI,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/D,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;IACnC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C;CAChG;AAED,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG,kBAAkB,GAAG,mBAAmB,CAAC"} |
| export * from './cosmos'; | ||
| export * from './vectis'; | ||
| export type { VectisWindow } from './window'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"} |
| import { AccountData, AminoSignResponse, DirectSignResponse, OfflineAminoSigner, OfflineDirectSigner, OfflineSigner, SignDoc, StdSignDoc } from './cosmos'; | ||
| type Algo = 'secp256k1' | 'ethsecp256k1'; | ||
| export interface KeyInfo { | ||
| algo: Algo; | ||
| name: string; | ||
| pubKey: Uint8Array; | ||
| address: string; | ||
| isNanoLedger: boolean; | ||
| isVectisAccount: boolean; | ||
| } | ||
| export interface CosmosProvider { | ||
| suggestChains(chainsInfo: ChainInfo[]): Promise<void>; | ||
| enable(chainIds: string | string[]): Promise<void>; | ||
| getSupportedChains(): Promise<ChainInfo[]>; | ||
| getKey(chainId: string): Promise<KeyInfo>; | ||
| getAccounts(chainId: string): Promise<AccountData[]>; | ||
| signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>; | ||
| signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>; | ||
| getOfflineSignerAmino(chainId: string): OfflineAminoSigner; | ||
| getOfflineSignerDirect(chainId: string): OfflineDirectSigner; | ||
| getOfflineSigner(chainId: string): OfflineSigner; | ||
| /** | ||
| * Detect what signer should use based on the key type | ||
| * Ex: Nano ledger only supports amino signing. | ||
| */ | ||
| getOfflineSignerAuto(chainId: string): Promise<OfflineSigner>; | ||
| } | ||
| export interface ChainInfo { | ||
| readonly rpcUrl: string; | ||
| readonly restUrl: string; | ||
| readonly chainId: string; | ||
| readonly chainName: string; | ||
| readonly prettyName: string; | ||
| readonly bech32Prefix: string; | ||
| readonly bip44: { | ||
| readonly coinType: number; | ||
| }; | ||
| readonly currencies: AppCurrency[]; | ||
| readonly stakeCurrency: Currency; | ||
| readonly feeCurrencies: FeeCurrency[]; | ||
| readonly features?: string[]; | ||
| readonly isSuggested?: boolean; | ||
| readonly ecosystem?: string; | ||
| } | ||
| export interface Currency { | ||
| readonly coinDenom: string; | ||
| readonly coinMinimalDenom: string; | ||
| readonly coinDecimals: number; | ||
| readonly coinGeckoId?: string; | ||
| readonly coinImageUrl?: string; | ||
| } | ||
| export interface CW20Currency extends Currency { | ||
| readonly type: 'cw20'; | ||
| readonly contractAddress: string; | ||
| } | ||
| export interface IBCCurrency extends Currency { | ||
| readonly paths: { | ||
| portId: string; | ||
| channelId: string; | ||
| }[]; | ||
| readonly originChainId: string | undefined; | ||
| readonly originCurrency: Currency | CW20Currency | undefined; | ||
| } | ||
| export type AppCurrency = Currency | CW20Currency | IBCCurrency; | ||
| export type FeeCurrency = WithGasPriceStep<AppCurrency>; | ||
| export type WithGasPriceStep<T> = T & { | ||
| readonly gasPriceStep?: { | ||
| readonly low: number; | ||
| readonly average: number; | ||
| readonly high: number; | ||
| }; | ||
| }; | ||
| export {}; | ||
| //# sourceMappingURL=vectis.d.ts.map |
| {"version":3,"file":"vectis.d.ts","sourceRoot":"","sources":["../../../../src/types/vectis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,KAAK,IAAI,GAAG,WAAW,GAAG,cAAc,CAAC;AACzC,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAA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AAE;QACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC"} |
| import { CosmosProvider } from './vectis'; | ||
| export interface VectisWindow { | ||
| vectis: { | ||
| cosmos: CosmosProvider; | ||
| version: string; | ||
| }; | ||
| } | ||
| //# sourceMappingURL=window.d.ts.map |
| {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../../../src/types/window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QACN,MAAM,EAAE,cAAc,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"} |
| export {}; |
| export {}; |
+25
-12
| { | ||
| "name": "@vectis/extension-client", | ||
| "version": "0.6.0", | ||
| "version": "0.7.0", | ||
| "description": "Client for vectis extension", | ||
| "main": "index.js", | ||
| "types": "index.d.ts", | ||
| "types": "./build/cjs/types/index.d.ts", | ||
| "main": "./build/cjs/index.js", | ||
| "license": "Apache-2.0", | ||
| "exports": { | ||
| ".": { | ||
| "import": { | ||
| "types": "./build/esm/types/index.d.ts", | ||
| "default": "./build/esm/index.mjs" | ||
| }, | ||
| "require": { | ||
| "types": "./build/cjs/types/index.d.ts", | ||
| "default": "./build/cjs/index.js" | ||
| } | ||
| } | ||
| }, | ||
| "publishConfig": { | ||
@@ -12,15 +24,16 @@ "access": "public", | ||
| }, | ||
| "files": [ | ||
| "build" | ||
| ], | ||
| "scripts": { | ||
| "prebuild": "rimraf dist", | ||
| "build": "tsc", | ||
| "postbuild": "cpy package.json dist", | ||
| "publish:dev": "npm run build && cd dist && npm publish --dry-run", | ||
| "publish:ci": "npm run build && cd dist && npm publish", | ||
| "prebuild": "rimraf build", | ||
| "build": "npm run build:esm && npm run build:cjs", | ||
| "build:esm": "tsc -p ./tsconfig.esm.json && mv build/esm/index.js build/esm/index.mjs", | ||
| "build:cjs": "tsc -p ./tsconfig.cjs.json", | ||
| "publish:dev": "npm run build && npm publish --dry-run", | ||
| "publish:ci": "npm run build && npm publish", | ||
| "prettier": "prettier --write \"src/**/*.ts\"" | ||
| }, | ||
| "devDependencies": { | ||
| "@cosmjs/amino": "^0.28.11", | ||
| "@cosmjs/proto-signing": "^0.28.11", | ||
| "cosmjs-types": "^0.5.0", | ||
| "cpy-cli": "^4.1.0", | ||
| "@types/long": "^4.0.1", | ||
| "prettier": "^2.7.1", | ||
@@ -27,0 +40,0 @@ "rimraf": "^3.0.2", |
| import { AminoSignResponse, StdSignDoc } from '@cosmjs/amino'; | ||
| import { DirectSignResponse, OfflineSigner } from '@cosmjs/proto-signing'; | ||
| import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx'; | ||
| import { CosmosProvider } from '../types/cosmos'; | ||
| import { ChainInfo, KeyInfo } from '../types/vectis'; | ||
| export declare function getClient(): CosmosProvider; | ||
| export declare function getSupportedChains(): Promise<ChainInfo[]>; | ||
| export declare function getKey(chainId: string): Promise<KeyInfo>; | ||
| export declare function getAccount(chainId: string): Promise<{ | ||
| address: string; | ||
| name: string; | ||
| }>; | ||
| export declare function getOfflineSigner(chainId: string): Promise<OfflineSigner>; | ||
| export declare function suggestChains(chainsInfo: ChainInfo[]): Promise<void>; | ||
| export declare function enable(chainId: string): Promise<void>; | ||
| export declare function signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>; | ||
| export declare function signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>; | ||
| export declare function isChainSupported(chainId: string): Promise<boolean>; | ||
| export declare function onAccountChange(handler: EventListener): void; | ||
| export declare function offAccountChange(handler: EventListener): void; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.offAccountChange = exports.onAccountChange = exports.isChainSupported = exports.signDirect = exports.signAmino = exports.enable = exports.suggestChains = exports.getOfflineSigner = exports.getAccount = exports.getKey = exports.getSupportedChains = exports.getClient = void 0; | ||
| function getClient() { | ||
| return window.vectis.cosmos; | ||
| } | ||
| exports.getClient = getClient; | ||
| async function getSupportedChains() { | ||
| return await window.vectis.cosmos.getSupportedChains(); | ||
| } | ||
| exports.getSupportedChains = getSupportedChains; | ||
| async function getKey(chainId) { | ||
| return await window.vectis.cosmos.getKey(chainId); | ||
| } | ||
| exports.getKey = getKey; | ||
| async function getAccount(chainId) { | ||
| const { address, name } = await getKey(chainId); | ||
| return { address, name }; | ||
| } | ||
| exports.getAccount = getAccount; | ||
| async function getOfflineSigner(chainId) { | ||
| return await window.vectis.cosmos.getOfflineSigner(chainId); | ||
| } | ||
| exports.getOfflineSigner = getOfflineSigner; | ||
| async function suggestChains(chainsInfo) { | ||
| await window.vectis.cosmos.suggestChains(chainsInfo); | ||
| } | ||
| exports.suggestChains = suggestChains; | ||
| async function enable(chainId) { | ||
| await window.vectis.cosmos.enable(chainId); | ||
| } | ||
| exports.enable = enable; | ||
| async function signAmino(signerAddress, doc) { | ||
| return await window.vectis.cosmos.signAmino(signerAddress, doc); | ||
| } | ||
| exports.signAmino = signAmino; | ||
| async function signDirect(signerAddress, doc) { | ||
| return await window.vectis.cosmos.signDirect(signerAddress, doc); | ||
| } | ||
| exports.signDirect = signDirect; | ||
| async function isChainSupported(chainId) { | ||
| const chains = await getSupportedChains(); | ||
| return chains.some((c) => c.chainId === chainId); | ||
| } | ||
| exports.isChainSupported = isChainSupported; | ||
| function onAccountChange(handler) { | ||
| window.addEventListener('vectis_accountChanged', handler); | ||
| } | ||
| exports.onAccountChange = onAccountChange; | ||
| function offAccountChange(handler) { | ||
| window.removeEventListener('vectis_accountChanged', handler); | ||
| } | ||
| exports.offAccountChange = offAccountChange; |
| import * as cosmosProvider from './cosmos/cosmos.provider'; | ||
| export declare type Cosmos = typeof cosmosProvider; | ||
| export { cosmosProvider }; | ||
| export declare function isInstalled(): boolean; | ||
| export declare function cosmos(): Promise<Cosmos>; |
-47
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.cosmos = exports.isInstalled = exports.cosmosProvider = void 0; | ||
| const cosmosProvider = __importStar(require("./cosmos/cosmos.provider")); | ||
| exports.cosmosProvider = cosmosProvider; | ||
| function isInstalled() { | ||
| return !!window.vectis; | ||
| } | ||
| exports.isInstalled = isInstalled; | ||
| function cosmos() { | ||
| return new Promise((resolve, reject) => { | ||
| const interval = setInterval(() => { | ||
| if (isInstalled()) { | ||
| clearInterval(interval); | ||
| resolve(cosmosProvider); | ||
| } | ||
| }, 100); | ||
| setTimeout(() => { | ||
| clearInterval(interval); | ||
| reject(new Error('Vectis is not installed')); | ||
| }, 500); | ||
| }); | ||
| } | ||
| exports.cosmos = cosmos; |
| import { OfflineDirectSigner, OfflineSigner, AccountData, DirectSignResponse } from '@cosmjs/proto-signing'; | ||
| import { AminoSignResponse, StdSignDoc, OfflineAminoSigner } from '@cosmjs/amino'; | ||
| import { SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx'; | ||
| import { ChainInfo, KeyInfo } from './vectis'; | ||
| export interface CosmosProvider { | ||
| suggestChains(chainsInfo: ChainInfo[]): Promise<void>; | ||
| enable(chainIds: string | string[]): Promise<void>; | ||
| getSupportedChains(): Promise<ChainInfo[]>; | ||
| getKey(chainId: string): Promise<KeyInfo>; | ||
| getAccounts(chainId: string): Promise<AccountData[]>; | ||
| signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>; | ||
| signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>; | ||
| getOfflineSignerAmino(chainId: string): OfflineAminoSigner; | ||
| getOfflineSignerDirect(chainId: string): OfflineDirectSigner; | ||
| getOfflineSigner(chainId: string): OfflineSigner; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| export { KeyInfo, ChainInfo } from './vectis'; | ||
| export { CosmosProvider } from './cosmos'; | ||
| export { VectisWindow } from './window'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| export interface KeyInfo { | ||
| name: string; | ||
| address: string; | ||
| isNanoLedger: boolean; | ||
| isSCWallet: boolean; | ||
| algo: 'secp256k1'; | ||
| pubkey: Uint8Array; | ||
| } | ||
| export interface ChainInfo { | ||
| readonly chainId: string; | ||
| readonly chainName: string; | ||
| readonly prettyName: string; | ||
| readonly bech32Prefix: string; | ||
| readonly rpcUrl: string; | ||
| readonly restUrl: string; | ||
| readonly bip44: BIP44; | ||
| readonly feeTokens: Currency[]; | ||
| readonly stakingToken: string; | ||
| readonly defaultGasPrice: number; | ||
| readonly defaultFeeToken: string; | ||
| readonly gasPriceStep?: { | ||
| low: number; | ||
| average: number; | ||
| high: number; | ||
| }; | ||
| readonly subqueryUrl?: string; | ||
| readonly vectisFactory?: string; | ||
| readonly features?: string[]; | ||
| readonly testnet?: boolean; | ||
| } | ||
| export interface BIP44 { | ||
| readonly coinType: number; | ||
| } | ||
| export interface Currency { | ||
| readonly denom: string; | ||
| readonly coinDecimals: number; | ||
| readonly coinGeckoId?: string; | ||
| readonly coinImageUrl?: string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| import { CosmosProvider } from './cosmos'; | ||
| export interface VectisWindow { | ||
| vectis: { | ||
| cosmos: CosmosProvider; | ||
| version: string; | ||
| }; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
40356
361.58%4
-42.86%37
184.62%663
233.17%1
Infinity%