@cartridge/controller 0.3.44 → 0.3.45
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/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/device.d.ts +3 -3
- package/dist/device.js +9 -4
- package/dist/device.js.map +1 -1
- package/dist/errors.d.ts +3 -5
- package/dist/errors.js +6 -8
- package/dist/errors.js.map +1 -1
- package/dist/iframe/base.d.ts +24 -0
- package/dist/iframe/base.js +91 -0
- package/dist/iframe/base.js.map +1 -0
- package/dist/iframe/index.d.ts +3 -0
- package/dist/iframe/index.js +4 -0
- package/dist/iframe/index.js.map +1 -0
- package/dist/iframe/keychain.d.ts +7 -0
- package/dist/iframe/keychain.js +19 -0
- package/dist/iframe/keychain.js.map +1 -0
- package/dist/iframe/profile.d.ts +10 -0
- package/dist/iframe/profile.js +16 -0
- package/dist/iframe/profile.js.map +1 -0
- package/dist/index.d.ts +10 -17
- package/dist/index.js +76 -78
- package/dist/index.js.map +1 -1
- package/dist/presets.js +18 -0
- package/dist/presets.js.map +1 -1
- package/dist/types.d.ts +33 -15
- package/package.json +3 -3
- package/dist/modal.d.ts +0 -5
- package/dist/modal.js +0 -62
- package/dist/modal.js.map +0 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const KEYCHAIN_URL = "https://x.cartridge.gg";
|
|
2
|
+
export declare const PROFILE_URL = "https://profile.cartridge.gg";
|
|
2
3
|
export declare const RPC_SEPOLIA = "https://api.cartridge.gg/x/starknet/sepolia";
|
|
3
4
|
export declare const RPC_MAINNET = "https://api.cartridge.gg/x/starknet/mainnet";
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const KEYCHAIN_URL = "https://x.cartridge.gg";
|
|
2
|
+
export const PROFILE_URL = "https://profile.cartridge.gg";
|
|
2
3
|
export const RPC_SEPOLIA = "https://api.cartridge.gg/x/starknet/sepolia";
|
|
3
4
|
export const RPC_MAINNET = "https://api.cartridge.gg/x/starknet/mainnet";
|
|
4
5
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,6CAA6C,CAAC;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,6CAA6C,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,6CAA6C,CAAC;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG,6CAA6C,CAAC"}
|
package/dist/device.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Account, Abi, Call, EstimateFeeDetails, Signature, InvokeFunctionResponse, EstimateFee, DeclareContractPayload, TypedData, InvocationsDetails } from "starknet";
|
|
2
|
-
import { Keychain,
|
|
2
|
+
import { Keychain, KeychainOptions, Modal } from "./types";
|
|
3
3
|
import { AsyncMethodReturns } from "@cartridge/penpal";
|
|
4
4
|
declare class DeviceAccount extends Account {
|
|
5
5
|
address: string;
|
|
6
6
|
private keychain;
|
|
7
7
|
private modal;
|
|
8
|
-
private
|
|
9
|
-
constructor(rpcUrl: string, address: string, keychain: AsyncMethodReturns<Keychain>,
|
|
8
|
+
private options?;
|
|
9
|
+
constructor(rpcUrl: string, address: string, keychain: AsyncMethodReturns<Keychain>, options: KeychainOptions, modal: Modal);
|
|
10
10
|
/**
|
|
11
11
|
* Estimate Fee for a method on starknet
|
|
12
12
|
*
|
package/dist/device.js
CHANGED
|
@@ -2,12 +2,12 @@ import { Account, RpcProvider, } from "starknet";
|
|
|
2
2
|
import { ResponseCodes, } from "./types";
|
|
3
3
|
import { Signer } from "./signer";
|
|
4
4
|
class DeviceAccount extends Account {
|
|
5
|
-
constructor(rpcUrl, address, keychain,
|
|
5
|
+
constructor(rpcUrl, address, keychain, options, modal) {
|
|
6
6
|
super(new RpcProvider({ nodeUrl: rpcUrl }), address, new Signer(keychain, modal));
|
|
7
7
|
this.address = address;
|
|
8
8
|
this.keychain = keychain;
|
|
9
|
+
this.options = options;
|
|
9
10
|
this.modal = modal;
|
|
10
|
-
this.paymaster = paymaster;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Estimate Fee for a method on starknet
|
|
@@ -45,16 +45,21 @@ class DeviceAccount extends Account {
|
|
|
45
45
|
// @ts-expect-error TODO: fix overload type mismatch
|
|
46
46
|
async execute(calls, abis, transactionsDetail = {}) {
|
|
47
47
|
return new Promise(async (resolve, reject) => {
|
|
48
|
-
const sessionExecute = await this.keychain.execute(calls, abis, transactionsDetail, false, this.paymaster);
|
|
48
|
+
const sessionExecute = await this.keychain.execute(calls, abis, transactionsDetail, false, this.options?.paymaster);
|
|
49
49
|
// Session call succeeded
|
|
50
50
|
if (sessionExecute.code === ResponseCodes.SUCCESS) {
|
|
51
51
|
resolve(sessionExecute);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
+
// Propagates session txn error back to caller
|
|
55
|
+
if (this.options?.propagateSessionErrors) {
|
|
56
|
+
reject(sessionExecute.error);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
54
59
|
// Session call or Paymaster flow failed.
|
|
55
60
|
// Session not avaialble, manual flow fallback
|
|
56
61
|
this.modal.open();
|
|
57
|
-
const manualExecute = await this.keychain.execute(calls, abis, transactionsDetail, true, this.paymaster, sessionExecute.error);
|
|
62
|
+
const manualExecute = await this.keychain.execute(calls, abis, transactionsDetail, true, this.options?.paymaster, sessionExecute.error);
|
|
58
63
|
// Manual call succeeded
|
|
59
64
|
if (manualExecute.code === ResponseCodes.SUCCESS) {
|
|
60
65
|
resolve(manualExecute);
|
package/dist/device.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAQP,WAAW,GAGZ,MAAM,UAAU,CAAC;AAElB,OAAO,EAKL,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,MAAM,aAAc,SAAQ,OAAO;IAMjC,YACE,MAAc,EACd,OAAe,EACf,QAAsC,EACtC,
|
|
1
|
+
{"version":3,"file":"device.js","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAQP,WAAW,GAGZ,MAAM,UAAU,CAAC;AAElB,OAAO,EAKL,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,MAAM,aAAc,SAAQ,OAAO;IAMjC,YACE,MAAc,EACd,OAAe,EACf,QAAsC,EACtC,OAAwB,EACxB,KAAY;QAEZ,KAAK,CACH,IAAI,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EACpC,OAAO,EACP,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAC5B,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,iBAAiB,CACrB,KAAoB,EACpB,OAA4B;QAE5B,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAA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C;gBACjD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,MAAM,CAAE,aAA8B,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO;QACT,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,SAAoB;QACpC,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAClB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACrE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO,GAAgB,CAAC;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF;AAED,eAAe,aAAa,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Policy } from "./types";
|
|
2
|
-
export declare class MissingPolicys extends Error {
|
|
3
|
-
missing: Policy[];
|
|
4
|
-
constructor(missing: Policy[]);
|
|
5
|
-
}
|
|
6
1
|
export declare class NotReadyToConnect extends Error {
|
|
7
2
|
constructor();
|
|
8
3
|
}
|
|
4
|
+
export declare class ProfileNotReady extends Error {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
package/dist/errors.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
export class MissingPolicys extends Error {
|
|
2
|
-
constructor(missing) {
|
|
3
|
-
super("missing policies");
|
|
4
|
-
this.missing = missing;
|
|
5
|
-
// because we are extending a built-in class
|
|
6
|
-
Object.setPrototypeOf(this, MissingPolicys.prototype);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
1
|
export class NotReadyToConnect extends Error {
|
|
10
2
|
constructor() {
|
|
11
3
|
super("Not ready to connect");
|
|
12
4
|
Object.setPrototypeOf(this, NotReadyToConnect.prototype);
|
|
13
5
|
}
|
|
14
6
|
}
|
|
7
|
+
export class ProfileNotReady extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("Profile is not ready");
|
|
10
|
+
Object.setPrototypeOf(this, NotReadyToConnect.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
15
13
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C;QACE,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAE9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC;QACE,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAE9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AsyncMethodReturns } from "@cartridge/penpal";
|
|
2
|
+
import { ControllerOptions, Modal } from "../types";
|
|
3
|
+
export type IFrameOptions<CallSender> = Omit<ConstructorParameters<typeof IFrame>[0], "id" | "url" | "onConnect"> & {
|
|
4
|
+
url?: string;
|
|
5
|
+
onConnect: (child: AsyncMethodReturns<CallSender>) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare class IFrame<CallSender extends {}> implements Modal {
|
|
8
|
+
private iframe?;
|
|
9
|
+
private container?;
|
|
10
|
+
private onClose?;
|
|
11
|
+
constructor({ id, url, theme, config, colorMode, onClose, onConnect, methods, }: Pick<ControllerOptions, "theme" | "config" | "colorMode"> & {
|
|
12
|
+
id: string;
|
|
13
|
+
url: URL;
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
onConnect: (child: AsyncMethodReturns<CallSender>) => void;
|
|
16
|
+
methods?: {
|
|
17
|
+
[key: string]: (...args: any[]) => void;
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
open(): void;
|
|
21
|
+
close(): void;
|
|
22
|
+
private append;
|
|
23
|
+
private resize;
|
|
24
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { connectToChild } from "@cartridge/penpal";
|
|
2
|
+
import { defaultPresets } from "../presets";
|
|
3
|
+
export class IFrame {
|
|
4
|
+
constructor({ id, url, theme, config, colorMode, onClose, onConnect, methods = {}, }) {
|
|
5
|
+
if (typeof document === "undefined") {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
url.searchParams.set("theme", encodeURIComponent(JSON.stringify(config?.presets?.[theme ?? "cartridge"] ?? defaultPresets.cartridge)));
|
|
9
|
+
if (colorMode) {
|
|
10
|
+
url.searchParams.set("colorMode", colorMode);
|
|
11
|
+
}
|
|
12
|
+
const iframe = document.createElement("iframe");
|
|
13
|
+
iframe.src = url.toString();
|
|
14
|
+
iframe.id = id;
|
|
15
|
+
iframe.style.border = "none";
|
|
16
|
+
iframe.sandbox.add("allow-forms");
|
|
17
|
+
iframe.sandbox.add("allow-popups");
|
|
18
|
+
iframe.sandbox.add("allow-scripts");
|
|
19
|
+
iframe.sandbox.add("allow-same-origin");
|
|
20
|
+
iframe.allow =
|
|
21
|
+
"publickey-credentials-create *; publickey-credentials-get *; clipboard-write";
|
|
22
|
+
if (!!document.hasStorageAccess) {
|
|
23
|
+
iframe.sandbox.add("allow-storage-access-by-user-activation");
|
|
24
|
+
}
|
|
25
|
+
const container = document.createElement("div");
|
|
26
|
+
container.style.position = "fixed";
|
|
27
|
+
container.style.height = "100%";
|
|
28
|
+
container.style.width = "100%";
|
|
29
|
+
container.style.top = "0";
|
|
30
|
+
container.style.left = "0";
|
|
31
|
+
container.style.zIndex = "10000";
|
|
32
|
+
container.style.backgroundColor = "rgba(0,0,0,0.6)";
|
|
33
|
+
container.style.display = "flex";
|
|
34
|
+
container.style.alignItems = "center";
|
|
35
|
+
container.style.justifyContent = "center";
|
|
36
|
+
container.style.visibility = "hidden";
|
|
37
|
+
container.style.opacity = "0";
|
|
38
|
+
container.style.transition = "opacity 0.2s ease";
|
|
39
|
+
container.appendChild(iframe);
|
|
40
|
+
this.iframe = iframe;
|
|
41
|
+
this.container = container;
|
|
42
|
+
connectToChild({
|
|
43
|
+
iframe: this.iframe,
|
|
44
|
+
methods: { close: () => this.close(), ...methods },
|
|
45
|
+
}).promise.then(onConnect);
|
|
46
|
+
this.resize();
|
|
47
|
+
window.addEventListener("resize", () => this.resize());
|
|
48
|
+
if (document.readyState === "complete" ||
|
|
49
|
+
document.readyState === "interactive") {
|
|
50
|
+
this.append();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
document.addEventListener("DOMContentLoaded", this.append);
|
|
54
|
+
}
|
|
55
|
+
this.onClose = onClose;
|
|
56
|
+
}
|
|
57
|
+
open() {
|
|
58
|
+
if (!this.container)
|
|
59
|
+
return;
|
|
60
|
+
document.body.style.overflow = "hidden";
|
|
61
|
+
this.container.style.visibility = "visible";
|
|
62
|
+
this.container.style.opacity = "1";
|
|
63
|
+
}
|
|
64
|
+
close() {
|
|
65
|
+
if (!this.container)
|
|
66
|
+
return;
|
|
67
|
+
this.onClose?.();
|
|
68
|
+
document.body.style.overflow = "auto";
|
|
69
|
+
this.container.style.visibility = "hidden";
|
|
70
|
+
this.container.style.opacity = "0";
|
|
71
|
+
}
|
|
72
|
+
append() {
|
|
73
|
+
if (!this.container)
|
|
74
|
+
return;
|
|
75
|
+
document.body.appendChild(this.container);
|
|
76
|
+
}
|
|
77
|
+
resize() {
|
|
78
|
+
if (!this.iframe)
|
|
79
|
+
return;
|
|
80
|
+
if (window.innerWidth < 768) {
|
|
81
|
+
this.iframe.style.height = "100%";
|
|
82
|
+
this.iframe.style.width = "100%";
|
|
83
|
+
this.iframe.style.borderRadius = "0";
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.iframe.style.height = "600px";
|
|
87
|
+
this.iframe.style.width = "432px";
|
|
88
|
+
this.iframe.style.borderRadius = "8px";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/iframe/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAW5C,MAAM,OAAO,MAAM;IAKjB,YAAY,EACV,EAAE,EACF,GAAG,EACH,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,SAAS,EACT,OAAO,GAAG,EAAE,GAOb;QACC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpC,OAAO;QACT,CAAC;QAED,GAAG,CAAC,YAAY,CAAC,GAAG,CAClB,OAAO,EACP,kBAAkB,CAChB,IAAI,CAAC,SAAS,CACZ,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,IAAI,WAAW,CAAC,IAAI,cAAc,CAAC,SAAS,CACpE,CACF,CACF,CAAC;QAEF,IAAI,SAAS,EAAE,CAAC;YACd,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC5B,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;QACf,MAAM,CAAC,KA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C;QAEtC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;IACrC,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO;QAC5B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO;QACzB,IAAI,MAAM,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,CAAC;YACrC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/iframe/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Keychain, KeychainOptions } from "../types";
|
|
2
|
+
import { IFrame, IFrameOptions } from "./base";
|
|
3
|
+
type KeychainIframeOptions = IFrameOptions<Keychain> & KeychainOptions;
|
|
4
|
+
export declare class KeychainIFrame extends IFrame<Keychain> {
|
|
5
|
+
constructor({ url, paymaster, policies, ...iframeOptions }: KeychainIframeOptions);
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { KEYCHAIN_URL } from "../constants";
|
|
2
|
+
import { IFrame } from "./base";
|
|
3
|
+
export class KeychainIFrame extends IFrame {
|
|
4
|
+
constructor({ url, paymaster, policies, ...iframeOptions }) {
|
|
5
|
+
const _url = new URL(url ?? KEYCHAIN_URL);
|
|
6
|
+
if (paymaster) {
|
|
7
|
+
_url.searchParams.set("paymaster", encodeURIComponent(JSON.stringify(paymaster)));
|
|
8
|
+
}
|
|
9
|
+
if (policies) {
|
|
10
|
+
_url.searchParams.set("policies", encodeURIComponent(JSON.stringify(policies)));
|
|
11
|
+
}
|
|
12
|
+
super({
|
|
13
|
+
...iframeOptions,
|
|
14
|
+
id: "controller-keychain",
|
|
15
|
+
url: _url,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=keychain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../../src/iframe/keychain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAiB,MAAM,QAAQ,CAAC;AAI/C,MAAM,OAAO,cAAe,SAAQ,MAAgB;IAClD,YAAY,EACV,GAAG,EACH,SAAS,EACT,QAAQ,EACR,GAAG,aAAa,EACM;QACtB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC;QAC1C,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,YAAY,CAAC,GAAG,CACnB,WAAW,EACX,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAC9C,CAAC;QACJ,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,YAAY,CAAC,GAAG,CACnB,UAAU,EACV,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAC7C,CAAC;QACJ,CAAC;QAED,KAAK,CAAC;YACJ,GAAG,aAAa;YAChB,EAAE,EAAE,qBAAqB;YACzB,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Profile, ProfileOptions } from "../types";
|
|
2
|
+
import { IFrame, IFrameOptions } from "./base";
|
|
3
|
+
export type ProfileIFrameOptions = IFrameOptions<Profile> & ProfileOptions & {
|
|
4
|
+
address: string;
|
|
5
|
+
username: string;
|
|
6
|
+
indexerUrl: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class ProfileIFrame extends IFrame<Profile> {
|
|
9
|
+
constructor({ profileUrl, address, username, indexerUrl, ...iframeOptions }: ProfileIFrameOptions);
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PROFILE_URL } from "../constants";
|
|
2
|
+
import { IFrame } from "./base";
|
|
3
|
+
export class ProfileIFrame extends IFrame {
|
|
4
|
+
constructor({ profileUrl, address, username, indexerUrl, ...iframeOptions }) {
|
|
5
|
+
const _url = new URL(profileUrl ?? PROFILE_URL);
|
|
6
|
+
_url.searchParams.set("address", encodeURIComponent(address));
|
|
7
|
+
_url.searchParams.set("username", encodeURIComponent(username));
|
|
8
|
+
_url.searchParams.set("indexerUrl", encodeURIComponent(indexerUrl));
|
|
9
|
+
super({
|
|
10
|
+
...iframeOptions,
|
|
11
|
+
id: "controller-profile",
|
|
12
|
+
url: _url,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/iframe/profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAiB,MAAM,QAAQ,CAAC;AAS/C,MAAM,OAAO,aAAc,SAAQ,MAAe;IAChD,YAAY,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,GAAG,aAAa,EACK;QACrB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,IAAI,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC;QAEpE,KAAK,CAAC;YACJ,GAAG,aAAa;YAChB,EAAE,EAAE,oBAAoB;YACxB,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,31 +3,24 @@ export * from "./types";
|
|
|
3
3
|
export { defaultPresets } from "./presets";
|
|
4
4
|
export * from "./verified";
|
|
5
5
|
import { AccountInterface } from "starknet";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
declare class Controller {
|
|
9
|
-
private url;
|
|
6
|
+
import { Policy, ControllerOptions, ProfileContextTypeVariant } from "./types";
|
|
7
|
+
export default class Controller {
|
|
10
8
|
private policies;
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
|
|
9
|
+
private keychain?;
|
|
10
|
+
private profile?;
|
|
11
|
+
private options;
|
|
12
|
+
private iframes;
|
|
15
13
|
rpc: URL;
|
|
16
14
|
account?: AccountInterface;
|
|
17
|
-
constructor({ policies, url, rpc, paymaster,
|
|
18
|
-
|
|
19
|
-
private initModal;
|
|
20
|
-
private setTheme;
|
|
21
|
-
private setColorMode;
|
|
22
|
-
private setPaymaster;
|
|
15
|
+
constructor({ policies, url, rpc, paymaster, ...options }?: ControllerOptions);
|
|
16
|
+
openSettings(): Promise<boolean | null>;
|
|
23
17
|
ready(): Promise<boolean>;
|
|
24
18
|
probe(): Promise<true | null | undefined>;
|
|
25
19
|
connect(): Promise<AccountInterface | undefined>;
|
|
20
|
+
openProfile(tab?: ProfileContextTypeVariant): void;
|
|
26
21
|
disconnect(): Promise<void>;
|
|
27
22
|
revoke(origin: string, _policy: Policy[]): Promise<void> | null;
|
|
28
23
|
username(): Promise<string> | undefined;
|
|
29
24
|
delegateAccount(): Promise<string | null>;
|
|
25
|
+
private waitForKeychain;
|
|
30
26
|
}
|
|
31
|
-
export * from "./types";
|
|
32
|
-
export * from "./errors";
|
|
33
|
-
export default Controller;
|
package/dist/index.js
CHANGED
|
@@ -3,111 +3,84 @@ export * from "./types";
|
|
|
3
3
|
export { defaultPresets } from "./presets";
|
|
4
4
|
export * from "./verified";
|
|
5
5
|
import { addAddressPadding } from "starknet";
|
|
6
|
-
import { connectToChild, } from "@cartridge/penpal";
|
|
7
6
|
import DeviceAccount from "./device";
|
|
8
7
|
import { ResponseCodes, } from "./types";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import { KeychainIFrame, ProfileIFrame } from "./iframe";
|
|
9
|
+
import { NotReadyToConnect, ProfileNotReady } from "./errors";
|
|
10
|
+
import { RPC_SEPOLIA } from "./constants";
|
|
11
|
+
export default class Controller {
|
|
12
|
+
constructor({ policies, url, rpc, paymaster, ...options } = {}) {
|
|
13
|
+
this.iframes = {
|
|
14
|
+
keychain: new KeychainIFrame({
|
|
15
|
+
...options,
|
|
16
|
+
url,
|
|
17
|
+
paymaster,
|
|
18
|
+
onClose: this.keychain?.reset,
|
|
19
|
+
onConnect: (keychain) => {
|
|
20
|
+
this.keychain = keychain;
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
17
24
|
this.rpc = new URL(rpc || RPC_SEPOLIA);
|
|
18
|
-
this.
|
|
25
|
+
// TODO: remove this on the next major breaking change. pass everthing by url
|
|
19
26
|
this.policies =
|
|
20
27
|
policies?.map((policy) => ({
|
|
21
28
|
...policy,
|
|
22
29
|
target: addAddressPadding(policy.target),
|
|
23
30
|
})) || [];
|
|
24
|
-
this.
|
|
25
|
-
if (colorMode) {
|
|
26
|
-
this.setColorMode(colorMode);
|
|
27
|
-
}
|
|
28
|
-
// if (prefunds?.length) {
|
|
29
|
-
// this.setPrefunds(prefunds);
|
|
30
|
-
// }
|
|
31
|
-
if (paymaster) {
|
|
32
|
-
this.setPaymaster(paymaster);
|
|
33
|
-
}
|
|
34
|
-
this.initModal();
|
|
31
|
+
this.options = options;
|
|
35
32
|
}
|
|
36
|
-
async
|
|
37
|
-
if (!this.keychain || !this.
|
|
33
|
+
async openSettings() {
|
|
34
|
+
if (!this.keychain || !this.iframes.keychain) {
|
|
38
35
|
console.error(new NotReadyToConnect().message);
|
|
39
36
|
return null;
|
|
40
37
|
}
|
|
41
|
-
this.
|
|
42
|
-
const res = await this.keychain.
|
|
43
|
-
this.
|
|
38
|
+
this.iframes.keychain.open();
|
|
39
|
+
const res = await this.keychain.openSettings();
|
|
40
|
+
this.iframes.keychain.close();
|
|
44
41
|
if (res && res.code === ResponseCodes.NOT_CONNECTED) {
|
|
45
42
|
return false;
|
|
46
43
|
}
|
|
47
44
|
return true;
|
|
48
45
|
}
|
|
49
|
-
initModal() {
|
|
50
|
-
if (typeof document === "undefined")
|
|
51
|
-
return;
|
|
52
|
-
this.modal = createModal(this.url.toString(), () => this.keychain?.reset());
|
|
53
|
-
const appendModal = () => document.body.appendChild(this.modal.element);
|
|
54
|
-
if (document.readyState === "complete" ||
|
|
55
|
-
document.readyState === "interactive") {
|
|
56
|
-
appendModal();
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
document.addEventListener("DOMContentLoaded", appendModal);
|
|
60
|
-
}
|
|
61
|
-
this.connection = connectToChild({
|
|
62
|
-
iframe: this.modal.element.children[0],
|
|
63
|
-
methods: { close: () => this.modal?.close() },
|
|
64
|
-
});
|
|
65
|
-
this.connection.promise.then((keychain) => {
|
|
66
|
-
this.keychain = keychain;
|
|
67
|
-
return this.probe();
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
setTheme(id = "cartridge", presets = defaultPresets) {
|
|
71
|
-
const theme = presets[id] ?? defaultPresets.cartridge;
|
|
72
|
-
this.url.searchParams.set("theme", encodeURIComponent(JSON.stringify(theme)));
|
|
73
|
-
}
|
|
74
|
-
// private setPrefunds(prefunds: Prefund[]) {
|
|
75
|
-
// this.url.searchParams.set(
|
|
76
|
-
// "prefunds",
|
|
77
|
-
// encodeURIComponent(JSON.stringify(prefunds)),
|
|
78
|
-
// );
|
|
79
|
-
// }
|
|
80
|
-
setColorMode(colorMode) {
|
|
81
|
-
this.url.searchParams.set("colorMode", colorMode);
|
|
82
|
-
}
|
|
83
|
-
setPaymaster(paymaster) {
|
|
84
|
-
this.url.searchParams.set("paymaster", encodeURIComponent(JSON.stringify(paymaster)));
|
|
85
|
-
}
|
|
86
46
|
ready() {
|
|
87
|
-
return
|
|
88
|
-
.then(() => this.probe())
|
|
89
|
-
.then((res) => !!res, () => false) ?? Promise.resolve(false));
|
|
47
|
+
return this.probe().then((res) => !!res, () => false);
|
|
90
48
|
}
|
|
91
49
|
async probe() {
|
|
92
|
-
if (!this.keychain || !this.modal) {
|
|
93
|
-
console.error(new NotReadyToConnect().message);
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
50
|
try {
|
|
51
|
+
await this.waitForKeychain();
|
|
52
|
+
if (!this.keychain) {
|
|
53
|
+
console.error(new NotReadyToConnect().message);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
97
56
|
const response = (await this.keychain.probe(this.rpc.toString()));
|
|
98
|
-
this.account = new DeviceAccount(this.rpc.toString(), response.address, this.keychain, this.
|
|
57
|
+
this.account = new DeviceAccount(this.rpc.toString(), response.address, this.keychain, this.options, this.iframes.keychain);
|
|
99
58
|
}
|
|
100
59
|
catch (e) {
|
|
101
60
|
console.error(new NotReadyToConnect().message);
|
|
102
61
|
return;
|
|
103
62
|
}
|
|
63
|
+
if (this.options.profileUrl &&
|
|
64
|
+
this.options.indexerUrl &&
|
|
65
|
+
!this.iframes.profile) {
|
|
66
|
+
const username = await this.keychain.username();
|
|
67
|
+
this.iframes.profile = new ProfileIFrame({
|
|
68
|
+
profileUrl: this.options.profileUrl,
|
|
69
|
+
indexerUrl: this.options.indexerUrl,
|
|
70
|
+
address: this.account.address,
|
|
71
|
+
username,
|
|
72
|
+
onConnect: (profile) => {
|
|
73
|
+
this.profile = profile;
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
104
77
|
return !!this.account;
|
|
105
78
|
}
|
|
106
79
|
async connect() {
|
|
107
80
|
if (this.account) {
|
|
108
81
|
return this.account;
|
|
109
82
|
}
|
|
110
|
-
if (!this.keychain || !this.
|
|
83
|
+
if (!this.keychain || !this.iframes.keychain) {
|
|
111
84
|
console.error(new NotReadyToConnect().message);
|
|
112
85
|
return;
|
|
113
86
|
}
|
|
@@ -117,23 +90,35 @@ class Controller {
|
|
|
117
90
|
await document.requestStorageAccess();
|
|
118
91
|
}
|
|
119
92
|
}
|
|
120
|
-
this.
|
|
93
|
+
this.iframes.keychain.open();
|
|
121
94
|
try {
|
|
122
95
|
let response = await this.keychain.connect(this.policies, this.rpc.toString());
|
|
123
96
|
if (response.code !== ResponseCodes.SUCCESS) {
|
|
124
97
|
throw new Error(response.message);
|
|
125
98
|
}
|
|
126
99
|
response = response;
|
|
127
|
-
this.account = new DeviceAccount(this.rpc.toString(), response.address, this.keychain, this.
|
|
100
|
+
this.account = new DeviceAccount(this.rpc.toString(), response.address, this.keychain, this.options, this.iframes.keychain);
|
|
128
101
|
return this.account;
|
|
129
102
|
}
|
|
130
103
|
catch (e) {
|
|
131
104
|
console.log(e);
|
|
132
105
|
}
|
|
133
106
|
finally {
|
|
134
|
-
this.
|
|
107
|
+
this.iframes.keychain.close();
|
|
135
108
|
}
|
|
136
109
|
}
|
|
110
|
+
openProfile(tab = "inventory") {
|
|
111
|
+
if (!this.options.indexerUrl) {
|
|
112
|
+
console.error("`indexerUrl` option is required to open profile");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!this.profile || !this.iframes.profile) {
|
|
116
|
+
console.error(new ProfileNotReady().message);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.profile.goTo(tab);
|
|
120
|
+
this.iframes.profile.open();
|
|
121
|
+
}
|
|
137
122
|
async disconnect() {
|
|
138
123
|
if (!this.keychain) {
|
|
139
124
|
console.error(new NotReadyToConnect().message);
|
|
@@ -169,8 +154,21 @@ class Controller {
|
|
|
169
154
|
}
|
|
170
155
|
return await this.keychain.delegateAccount();
|
|
171
156
|
}
|
|
157
|
+
waitForKeychain({ timeout = 3000, interval = 100, } = {}) {
|
|
158
|
+
return new Promise((resolve, reject) => {
|
|
159
|
+
const startTime = Date.now();
|
|
160
|
+
const id = setInterval(() => {
|
|
161
|
+
if (Date.now() - startTime > timeout) {
|
|
162
|
+
clearInterval(id);
|
|
163
|
+
reject(new Error("Timeout waiting for keychain"));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (!this.keychain)
|
|
167
|
+
return;
|
|
168
|
+
clearInterval(id);
|
|
169
|
+
resolve();
|
|
170
|
+
}, interval);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
172
173
|
}
|
|
173
|
-
export * from "./types";
|
|
174
|
-
export * from "./errors";
|
|
175
|
-
export default Controller;
|
|
176
174
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],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
|
+
"savage-summit": {
|
|
112
|
+
id: "savage-summit",
|
|
113
|
+
name: "Savage Summit",
|
|
114
|
+
icon: "/whitelabel/savage-summit/icon.png",
|
|
115
|
+
cover: "/whitelabel/savage-summit/cover.png",
|
|
116
|
+
colors: {
|
|
117
|
+
primary: "#fbf7da",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
"dark-shuffle": {
|
|
121
|
+
id: "dark-shuffle",
|
|
122
|
+
name: "Dark Shuffle",
|
|
123
|
+
icon: "/whitelabel/dark-shuffle/icon.svg",
|
|
124
|
+
cover: "/whitelabel/dark-shuffle/cover.png",
|
|
125
|
+
colors: {
|
|
126
|
+
primary: "#F59100",
|
|
127
|
+
},
|
|
128
|
+
},
|
|
111
129
|
};
|
|
112
130
|
//# sourceMappingURL=presets.js.map
|
package/dist/presets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAA2B;IACpD,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,gCAAgC;QACtC,KAAK,EAAE;YACL,KAAK,EAAE,uCAAuC;YAC9C,IAAI,EAAE,sCAAsC;SAC7C;KACF;IACD,aAAa,EAAE;QACb,EAAE,EAAE,aAAa;QACjB,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,kCAAkC;QACxC,KAAK,EAAE,mCAAmC;QAC1C,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;IACD,KAAK,EAAE;QACL,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,4BAA4B;QAClC,KAAK,EAAE,6BAA6B;QACpC,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;IACD,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,uBAAuB;QAC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AAqC;QAC3C,KAAK,EAAE,sCAAsC;QAC7C,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;IACD,UAAU,EAAE;QACV,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,iCAAiC;QACvC,KAAK,EAAE,kCAAkC;QACzC,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAA2B;IACpD,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,gCAAgC;QACtC,KAAK,EAAE;YACL,KAAK,EAAE,uCAAuC;YAC9C,IAAI,EAAE,sCAAsC;SAC7C;KACF;IACD,aAAa,EAAE;QACb,EAAE,EAAE,aAAa;QACjB,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,kCAAkC;QACxC,KAAK,EAAE,mCAAmC;QAC1C,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;IACD,KAAK,EAAE;QACL,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,4BAA4B;QAClC,KAAK,EAAE,6BAA6B;QACpC,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;IACD,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE,8BAA8B;QACpC,KAAK,EAAE,+BAA+B;QACtC,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;IACD,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,8BAA8B;QACpC,KAAK,EAAE,+BAA+B;QACtC,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;YAClB,iBAAiB,EAAE,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AAE,EAAE,eAAe;QACnB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,oCAAoC;QAC1C,KAAK,EAAE,qCAAqC;QAC5C,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;IACD,cAAc,EAAE;QACd,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,mCAAmC;QACzC,KAAK,EAAE,oCAAoC;QAC3C,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;KACF;CACF,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { constants, Abi, Call, InvocationsDetails, TypedData, InvokeFunctionResponse, Signature, EstimateFeeDetails, EstimateFee, DeclareContractPayload, BigNumberish, InvocationsSignerDetails, DeployAccountSignerDetails, DeclareSignerDetails } from "starknet";
|
|
2
|
+
import { KeychainIFrame, ProfileIFrame } from "./iframe";
|
|
3
|
+
import wasm from "@cartridge/account-wasm";
|
|
2
4
|
export type Session = {
|
|
3
5
|
chainId: constants.StarknetChainId;
|
|
4
6
|
policies: Policy[];
|
|
@@ -9,9 +11,7 @@ export type Session = {
|
|
|
9
11
|
privateKey: string;
|
|
10
12
|
};
|
|
11
13
|
};
|
|
12
|
-
export type Policy = {
|
|
13
|
-
target: string;
|
|
14
|
-
method?: string;
|
|
14
|
+
export type Policy = wasm.Policy & {
|
|
15
15
|
description?: string;
|
|
16
16
|
};
|
|
17
17
|
export declare enum ResponseCodes {
|
|
@@ -49,6 +49,10 @@ export type DeployReply = {
|
|
|
49
49
|
code: ResponseCodes.SUCCESS;
|
|
50
50
|
transaction_hash: string;
|
|
51
51
|
};
|
|
52
|
+
export type IFrames = {
|
|
53
|
+
keychain: KeychainIFrame;
|
|
54
|
+
profile?: ProfileIFrame;
|
|
55
|
+
};
|
|
52
56
|
export interface Keychain {
|
|
53
57
|
probe(rpcUrl?: string): Promise<ProbeReply | ConnectError>;
|
|
54
58
|
connect(policies: Policy[], rpcUrl: string): Promise<ConnectReply | ConnectError>;
|
|
@@ -60,7 +64,7 @@ export interface Keychain {
|
|
|
60
64
|
estimateInvokeFee(calls: Call | Call[], estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
61
65
|
execute(calls: Call | Call[], abis?: Abi[], transactionsDetail?: InvocationsDetails, sync?: boolean, paymaster?: PaymasterOptions, error?: ControllerError): Promise<ExecuteReply | ConnectError>;
|
|
62
66
|
logout(): Promise<void>;
|
|
63
|
-
|
|
67
|
+
openSettings(): Promise<void | ConnectError>;
|
|
64
68
|
session(): Promise<Session>;
|
|
65
69
|
sessions(): Promise<{
|
|
66
70
|
[key: string]: Session;
|
|
@@ -72,24 +76,18 @@ export interface Keychain {
|
|
|
72
76
|
username(): string;
|
|
73
77
|
delegateAccount(): string;
|
|
74
78
|
}
|
|
79
|
+
export interface Profile {
|
|
80
|
+
goTo(tab: ProfileContextTypeVariant): void;
|
|
81
|
+
}
|
|
75
82
|
export interface Modal {
|
|
76
|
-
element: HTMLDivElement;
|
|
77
83
|
open: () => void;
|
|
78
84
|
close: () => void;
|
|
79
85
|
}
|
|
80
86
|
/**
|
|
81
87
|
* Options for configuring the controller
|
|
82
88
|
*/
|
|
83
|
-
export type ControllerOptions =
|
|
84
|
-
|
|
85
|
-
/** The URL of keychain */
|
|
86
|
-
url?: string;
|
|
87
|
-
/** The URL of the RPC */
|
|
88
|
-
rpc?: string;
|
|
89
|
-
/** The origin of keychain */
|
|
90
|
-
origin?: string;
|
|
91
|
-
/** Paymaster options for transaction fee management */
|
|
92
|
-
paymaster?: PaymasterOptions;
|
|
89
|
+
export type ControllerOptions = KeychainOptions & ProfileOptions;
|
|
90
|
+
export type IFrameOptions = {
|
|
93
91
|
/** The ID of the starter pack to use */
|
|
94
92
|
starterPackId?: string;
|
|
95
93
|
/** The theme to use */
|
|
@@ -102,6 +100,26 @@ export type ControllerOptions = {
|
|
|
102
100
|
presets?: ControllerThemePresets;
|
|
103
101
|
};
|
|
104
102
|
};
|
|
103
|
+
export type KeychainOptions = IFrameOptions & {
|
|
104
|
+
policies?: Policy[];
|
|
105
|
+
/** The URL of keychain */
|
|
106
|
+
url?: string;
|
|
107
|
+
/** The URL of the RPC */
|
|
108
|
+
rpc?: string;
|
|
109
|
+
/** The origin of keychain */
|
|
110
|
+
origin?: string;
|
|
111
|
+
/** Paymaster options for transaction fee management */
|
|
112
|
+
paymaster?: PaymasterOptions;
|
|
113
|
+
/** Propagate transaction errors back to caller instead of showing modal */
|
|
114
|
+
propagateSessionErrors?: boolean;
|
|
115
|
+
};
|
|
116
|
+
export type ProfileOptions = IFrameOptions & {
|
|
117
|
+
/** The URL of profile. Mainly for internal development purpose */
|
|
118
|
+
profileUrl?: string;
|
|
119
|
+
/** The URL of Torii indexer. Will be mandatory once profile page is in production */
|
|
120
|
+
indexerUrl?: string;
|
|
121
|
+
};
|
|
122
|
+
export type ProfileContextTypeVariant = "quest" | "inventory" | "history";
|
|
105
123
|
/**
|
|
106
124
|
* Options for configuring a paymaster
|
|
107
125
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartridge/controller",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.45",
|
|
4
4
|
"description": "Cartridge Controller",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"fast-deep-equal": "^3.1.3",
|
|
16
16
|
"query-string": "^7.1.1",
|
|
17
17
|
"starknet": "^6.11.0",
|
|
18
|
-
"@cartridge/account-wasm": "^0.3.
|
|
18
|
+
"@cartridge/account-wasm": "^0.3.45"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/node": "^20.6.0",
|
|
22
22
|
"typescript": "^5.4.5",
|
|
23
|
-
"@cartridge/tsconfig": "^0.3.
|
|
23
|
+
"@cartridge/tsconfig": "^0.3.45"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build:deps": "tsc",
|
package/dist/modal.d.ts
DELETED
package/dist/modal.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export const createModal = (src, onClose) => {
|
|
2
|
-
const iframe = document.createElement("iframe");
|
|
3
|
-
iframe.src = src;
|
|
4
|
-
iframe.id = "cartridge-modal";
|
|
5
|
-
iframe.style.border = "none";
|
|
6
|
-
iframe.sandbox.add("allow-forms");
|
|
7
|
-
iframe.sandbox.add("allow-popups");
|
|
8
|
-
iframe.sandbox.add("allow-scripts");
|
|
9
|
-
iframe.sandbox.add("allow-same-origin");
|
|
10
|
-
iframe.allow =
|
|
11
|
-
"publickey-credentials-create *; publickey-credentials-get *; clipboard-write";
|
|
12
|
-
if (!!document.hasStorageAccess) {
|
|
13
|
-
iframe.sandbox.add("allow-storage-access-by-user-activation");
|
|
14
|
-
}
|
|
15
|
-
const container = document.createElement("div");
|
|
16
|
-
container.style.position = "fixed";
|
|
17
|
-
container.style.height = "100%";
|
|
18
|
-
container.style.width = "100%";
|
|
19
|
-
container.style.top = "0";
|
|
20
|
-
container.style.left = "0";
|
|
21
|
-
container.style.zIndex = "10000";
|
|
22
|
-
container.style.backgroundColor = "rgba(0,0,0,0.6)";
|
|
23
|
-
container.style.display = "flex";
|
|
24
|
-
container.style.alignItems = "center";
|
|
25
|
-
container.style.justifyContent = "center";
|
|
26
|
-
container.style.visibility = "hidden";
|
|
27
|
-
container.style.opacity = "0";
|
|
28
|
-
container.style.transition = "opacity 0.2s ease";
|
|
29
|
-
container.appendChild(iframe);
|
|
30
|
-
const open = () => {
|
|
31
|
-
document.body.style.overflow = "hidden";
|
|
32
|
-
container.style.visibility = "visible";
|
|
33
|
-
container.style.opacity = "1";
|
|
34
|
-
};
|
|
35
|
-
const close = () => {
|
|
36
|
-
if (onClose) {
|
|
37
|
-
onClose();
|
|
38
|
-
}
|
|
39
|
-
document.body.style.overflow = "auto";
|
|
40
|
-
container.style.visibility = "hidden";
|
|
41
|
-
container.style.opacity = "0";
|
|
42
|
-
};
|
|
43
|
-
resize(iframe);
|
|
44
|
-
window.addEventListener("resize", () => resize(iframe));
|
|
45
|
-
return {
|
|
46
|
-
element: container,
|
|
47
|
-
open,
|
|
48
|
-
close,
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
const resize = (el) => {
|
|
52
|
-
if (window.innerWidth < 768) {
|
|
53
|
-
el.style.height = "100%";
|
|
54
|
-
el.style.width = "100%";
|
|
55
|
-
el.style.borderRadius = "0";
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
el.style.height = "600px";
|
|
59
|
-
el.style.width = "432px";
|
|
60
|
-
el.style.borderRadius = "8px";
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=modal.js.map
|
package/dist/modal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sourceRoot":"","sources":["../src/modal.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,OAAoB,EAAE,EAAE;IAC/D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,MAAM,CAAC,EAAE,GAAG,iBAAiB,CAAC;IAC9B,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC7B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAClC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACpC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK;QACV,8EAA8E,CAAC;IACjF,IAAI,CAAC,CAAC,QAAQ,CAAC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