@cartridge/controller
Advanced tools
Comparing version 0.1.37 to 0.1.38
import { Message, Messenger } from "./messenger"; | ||
import { Scope } from "./types"; | ||
import { AccountInterface } from "starknet"; | ||
export declare class Cartridge { | ||
declare class Controller { | ||
private selector; | ||
@@ -18,6 +18,10 @@ private messenger?; | ||
probe(): Promise<AccountInterface | undefined>; | ||
register(address: string): Promise<{ | ||
publicKey: string; | ||
}>; | ||
connect(): Promise<AccountInterface | null>; | ||
} | ||
export default Controller; | ||
export type { Message }; | ||
export { Messenger }; | ||
export * from "./types"; |
@@ -41,4 +41,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import qs from "query-string"; | ||
var Cartridge = /** @class */ (function () { | ||
function Cartridge(scopes, options) { | ||
var Controller = /** @class */ (function () { | ||
function Controller(scopes, options) { | ||
var _this = this; | ||
@@ -99,3 +99,3 @@ this.selector = "cartridge-messenger"; | ||
} | ||
Cartridge.prototype.ready = function () { | ||
Controller.prototype.ready = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -109,6 +109,6 @@ return __generator(this, function (_a) { | ||
}; | ||
Cartridge.prototype.probe = function () { | ||
Controller.prototype.probe = function () { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var prob; | ||
var probe; | ||
return __generator(this, function (_c) { | ||
@@ -120,5 +120,5 @@ switch (_c.label) { | ||
case 1: | ||
prob = _c.sent(); | ||
if (this.messenger && ((_b = prob === null || prob === void 0 ? void 0 : prob.result) === null || _b === void 0 ? void 0 : _b.address)) { | ||
this.account = new Account(prob.result.address, prob.result.scopes, this.messenger, { | ||
probe = _c.sent(); | ||
if (this.messenger && ((_b = probe === null || probe === void 0 ? void 0 : probe.result) === null || _b === void 0 ? void 0 : _b.address)) { | ||
this.account = new Account(probe.result.address, probe.result.scopes, this.messenger, { | ||
url: this.url, | ||
@@ -133,5 +133,28 @@ }); | ||
}; | ||
Cartridge.prototype.connect = function () { | ||
// Register a new device key. | ||
Controller.prototype.register = function (address) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var register; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, ((_a = this.messenger) === null || _a === void 0 ? void 0 : _a.send({ | ||
method: "register", | ||
params: { | ||
address: address | ||
} | ||
}))]; | ||
case 1: | ||
register = _b.sent(); | ||
if (!register || register.error) { | ||
throw new Error("registration error"); | ||
} | ||
return [2 /*return*/, register.result]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Controller.prototype.connect = function () { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var id, ok, response; | ||
@@ -181,7 +204,7 @@ return __generator(this, function (_b) { | ||
}; | ||
return Cartridge; | ||
return Controller; | ||
}()); | ||
export { Cartridge }; | ||
export default Controller; | ||
export { Messenger }; | ||
export * from "./types"; | ||
//# sourceMappingURL=index.js.map |
@@ -106,3 +106,2 @@ import { DeployContractPayload, DeployContractResponse as StarknetDeployContractResponse, Abi, Call, InvocationsDetails, typedData, InvokeFunctionResponse, Signature } from "starknet"; | ||
params: { | ||
username: string; | ||
address: string; | ||
@@ -109,0 +108,0 @@ }; |
{ | ||
"name": "@cartridge/controller", | ||
"version": "0.1.37", | ||
"version": "0.1.38", | ||
"description": "Cartridge Controller", | ||
@@ -10,2 +10,3 @@ "main": "lib", | ||
"build": "tsc", | ||
"prepublish": "yarn build", | ||
"dev": "tsc --watch", | ||
@@ -12,0 +13,0 @@ "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"" |
Sorry, the diff of this file is not supported yet
107495
1166