@cartridge/controller 0.3.45 → 0.4.0
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/.turbo/turbo-build$colon$deps.log +4 -0
- package/dist/{index.d.ts → controller.d.ts} +3 -3
- package/dist/{index.js → controller.js} +15 -7
- package/dist/controller.js.map +1 -0
- package/dist/iframe/profile.d.ts +2 -1
- package/dist/iframe/profile.js +5 -1
- package/dist/iframe/profile.js.map +1 -1
- package/dist/presets.js +9 -0
- package/dist/presets.js.map +1 -1
- package/dist/session.d.ts +40 -0
- package/dist/session.js +44 -0
- package/dist/session.js.map +1 -0
- package/dist/signer.d.ts +27 -1
- package/dist/signer.js +35 -0
- package/dist/signer.js.map +1 -1
- package/dist/types.d.ts +21 -4
- package/dist/utils.d.ts +6 -1
- package/dist/utils.js +10 -23
- package/dist/utils.js.map +1 -1
- package/package.json +19 -8
- package/src/constants.ts +4 -0
- package/src/controller.ts +271 -0
- package/src/device.ts +162 -0
- package/src/errors.ts +15 -0
- package/src/iframe/base.ts +140 -0
- package/src/iframe/index.ts +3 -0
- package/src/iframe/keychain.ts +34 -0
- package/src/iframe/profile.ts +42 -0
- package/src/presets.ts +140 -0
- package/src/session.ts +92 -0
- package/src/signer.ts +144 -0
- package/src/types.ts +246 -0
- package/src/utils.ts +21 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/index.js.map +0 -1
- package/dist/verified.d.ts +0 -5
- package/dist/verified.js +0 -7
- package/dist/verified.js.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { AccountInterface } from "starknet";
|
|
2
|
+
import { Policy, ControllerOptions, ProfileContextTypeVariant } from "./types";
|
|
1
3
|
export * from "./errors";
|
|
2
4
|
export * from "./types";
|
|
3
5
|
export { defaultPresets } from "./presets";
|
|
4
|
-
export * from "./verified";
|
|
5
|
-
import { AccountInterface } from "starknet";
|
|
6
|
-
import { Policy, ControllerOptions, ProfileContextTypeVariant } from "./types";
|
|
7
6
|
export default class Controller {
|
|
8
7
|
private policies;
|
|
9
8
|
private keychain?;
|
|
@@ -21,6 +20,7 @@ export default class Controller {
|
|
|
21
20
|
disconnect(): Promise<void>;
|
|
22
21
|
revoke(origin: string, _policy: Policy[]): Promise<void> | null;
|
|
23
22
|
username(): Promise<string> | undefined;
|
|
23
|
+
fetchControllers(contractAddresses: string[]): Promise<Record<string, string>>;
|
|
24
24
|
delegateAccount(): Promise<string | null>;
|
|
25
25
|
private waitForKeychain;
|
|
26
26
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
export * from "./errors";
|
|
2
|
-
export * from "./types";
|
|
3
|
-
export { defaultPresets } from "./presets";
|
|
4
|
-
export * from "./verified";
|
|
5
1
|
import { addAddressPadding } from "starknet";
|
|
6
2
|
import DeviceAccount from "./device";
|
|
7
3
|
import { ResponseCodes, } from "./types";
|
|
8
4
|
import { KeychainIFrame, ProfileIFrame } from "./iframe";
|
|
9
5
|
import { NotReadyToConnect, ProfileNotReady } from "./errors";
|
|
10
6
|
import { RPC_SEPOLIA } from "./constants";
|
|
7
|
+
export * from "./errors";
|
|
8
|
+
export * from "./types";
|
|
9
|
+
export { defaultPresets } from "./presets";
|
|
11
10
|
export default class Controller {
|
|
12
11
|
constructor({ policies, url, rpc, paymaster, ...options } = {}) {
|
|
13
12
|
this.iframes = {
|
|
@@ -57,6 +56,7 @@ export default class Controller {
|
|
|
57
56
|
this.account = new DeviceAccount(this.rpc.toString(), response.address, this.keychain, this.options, this.iframes.keychain);
|
|
58
57
|
}
|
|
59
58
|
catch (e) {
|
|
59
|
+
console.log(e);
|
|
60
60
|
console.error(new NotReadyToConnect().message);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
@@ -69,6 +69,8 @@ export default class Controller {
|
|
|
69
69
|
indexerUrl: this.options.indexerUrl,
|
|
70
70
|
address: this.account.address,
|
|
71
71
|
username,
|
|
72
|
+
rpcUrl: this.rpc.toString(),
|
|
73
|
+
tokens: this.options.tokens,
|
|
72
74
|
onConnect: (profile) => {
|
|
73
75
|
this.profile = profile;
|
|
74
76
|
},
|
|
@@ -116,7 +118,7 @@ export default class Controller {
|
|
|
116
118
|
console.error(new ProfileNotReady().message);
|
|
117
119
|
return;
|
|
118
120
|
}
|
|
119
|
-
this.profile.
|
|
121
|
+
this.profile.navigate(tab);
|
|
120
122
|
this.iframes.profile.open();
|
|
121
123
|
}
|
|
122
124
|
async disconnect() {
|
|
@@ -147,6 +149,12 @@ export default class Controller {
|
|
|
147
149
|
}
|
|
148
150
|
return this.keychain.username();
|
|
149
151
|
}
|
|
152
|
+
fetchControllers(contractAddresses) {
|
|
153
|
+
if (!this.keychain) {
|
|
154
|
+
throw new NotReadyToConnect().message;
|
|
155
|
+
}
|
|
156
|
+
return this.keychain.fetchControllers(contractAddresses);
|
|
157
|
+
}
|
|
150
158
|
async delegateAccount() {
|
|
151
159
|
if (!this.keychain) {
|
|
152
160
|
console.error(new NotReadyToConnect().message);
|
|
@@ -154,7 +162,7 @@ export default class Controller {
|
|
|
154
162
|
}
|
|
155
163
|
return await this.keychain.delegateAccount();
|
|
156
164
|
}
|
|
157
|
-
waitForKeychain({ timeout =
|
|
165
|
+
waitForKeychain({ timeout = 5000, interval = 100, } = {}) {
|
|
158
166
|
return new Promise((resolve, reject) => {
|
|
159
167
|
const startTime = Date.now();
|
|
160
168
|
const id = setInterval(() => {
|
|
@@ -171,4 +179,4 @@ export default class Controller {
|
|
|
171
179
|
});
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
|
-
//# sourceMappingURL=
|
|
182
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG/D,OAAO,aAAa,MAAM,UAAU,CAAC;AACrC,OAAO,EAGL,aAAa,GAQd,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;
|
|
6
6
|
indexerUrl: string;
|
|
7
|
+
rpcUrl: string;
|
|
7
8
|
};
|
|
8
9
|
export declare class ProfileIFrame extends IFrame<Profile> {
|
|
9
|
-
constructor({ profileUrl, address, username, indexerUrl, ...iframeOptions }: ProfileIFrameOptions);
|
|
10
|
+
constructor({ profileUrl, address, username, indexerUrl, rpcUrl, tokens, ...iframeOptions }: ProfileIFrameOptions);
|
|
10
11
|
}
|
package/dist/iframe/profile.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { PROFILE_URL } from "../constants";
|
|
2
2
|
import { IFrame } from "./base";
|
|
3
3
|
export class ProfileIFrame extends IFrame {
|
|
4
|
-
constructor({ profileUrl, address, username, indexerUrl, ...iframeOptions }) {
|
|
4
|
+
constructor({ profileUrl, address, username, indexerUrl, rpcUrl, tokens, ...iframeOptions }) {
|
|
5
5
|
const _url = new URL(profileUrl ?? PROFILE_URL);
|
|
6
6
|
_url.searchParams.set("address", encodeURIComponent(address));
|
|
7
7
|
_url.searchParams.set("username", encodeURIComponent(username));
|
|
8
8
|
_url.searchParams.set("indexerUrl", encodeURIComponent(indexerUrl));
|
|
9
|
+
_url.searchParams.set("rpcUrl", encodeURIComponent(rpcUrl));
|
|
10
|
+
if (tokens?.erc20) {
|
|
11
|
+
_url.searchParams.set("erc20", encodeURIComponent(JSON.stringify(tokens.erc20)));
|
|
12
|
+
}
|
|
9
13
|
super({
|
|
10
14
|
...iframeOptions,
|
|
11
15
|
id: "controller-profile",
|
|
@@ -1 +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;
|
|
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;AAU/C,MAAM,OAAO,aAAc,SAAQ,MAAe;IAChD,YAAY,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,MAAM,EACN,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;QACpE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;QAE5D,IAAI,MAAM,EAAE,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,YAAY,CAAC,GAAG,CACnB,OAAO,EACP,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CACjD,CAAC;QACJ,CAAC;QAED,KAAK,CAAC;YACJ,GAAG,aAAa;YAChB,EAAE,EAAE,oBAAoB;YACxB,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/presets.js
CHANGED
|
@@ -126,5 +126,14 @@ export const defaultPresets = {
|
|
|
126
126
|
primary: "#F59100",
|
|
127
127
|
},
|
|
128
128
|
},
|
|
129
|
+
"blob-arena": {
|
|
130
|
+
id: "blob-arena",
|
|
131
|
+
name: "Blob Arena",
|
|
132
|
+
icon: "/whitelabel/blob-arena/icon.png",
|
|
133
|
+
cover: "/whitelabel/blob-arena/cover.png",
|
|
134
|
+
colors: {
|
|
135
|
+
primary: "#980f06",
|
|
136
|
+
},
|
|
137
|
+
},
|
|
129
138
|
};
|
|
130
139
|
//# 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;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,OAAO;SAC3B;KACF;IACD,WAAW,EAAE;QACX,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,gCAAgC;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,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"}
|
|
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,OAAO;SAC3B;KACF;IACD,WAAW,EAAE;QACX,EAAE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B,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;IACD,YAAY,EAAE;QACZ,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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Policy } from "@cartridge/account-wasm";
|
|
2
|
+
import { CartridgeSessionAccount } from "@cartridge/account-wasm/session";
|
|
3
|
+
import { Abi, Account, Call, InvokeFunctionResponse, Signature, TypedData, UniversalDetails } from "starknet";
|
|
4
|
+
export * from "./errors";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export { defaultPresets } from "./presets";
|
|
7
|
+
export default class SessionAccount extends Account {
|
|
8
|
+
controller: CartridgeSessionAccount;
|
|
9
|
+
constructor({ rpcUrl, privateKey, address, ownerGuid, chainId, expiresAt, policies, }: {
|
|
10
|
+
rpcUrl: string;
|
|
11
|
+
privateKey: string;
|
|
12
|
+
address: string;
|
|
13
|
+
ownerGuid: string;
|
|
14
|
+
chainId: string;
|
|
15
|
+
expiresAt: number;
|
|
16
|
+
policies: Policy[];
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Invoke execute function in account contract
|
|
20
|
+
*
|
|
21
|
+
* @param calls the invocation object or an array of them, containing:
|
|
22
|
+
* - contractAddress - the address of the contract
|
|
23
|
+
* - entrypoint - the entrypoint of the contract
|
|
24
|
+
* - calldata - (defaults to []) the calldata
|
|
25
|
+
* - signature - (defaults to []) the signature
|
|
26
|
+
* @param abis (optional) the abi of the contract for better displaying
|
|
27
|
+
*
|
|
28
|
+
* @returns response from addTransaction
|
|
29
|
+
*/
|
|
30
|
+
execute(calls: Call | Call[], _abisOrDetails?: Abi[] | UniversalDetails, _transactionsDetail?: UniversalDetails): Promise<InvokeFunctionResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
33
|
+
* This adds a message prefix so it cant be interchanged with transactions
|
|
34
|
+
*
|
|
35
|
+
* @param json - JSON object to be signed
|
|
36
|
+
* @returns the signature of the JSON object
|
|
37
|
+
* @throws {Error} if the JSON object is not a valid JSON
|
|
38
|
+
*/
|
|
39
|
+
signMessage(_typedData: TypedData): Promise<Signature>;
|
|
40
|
+
}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CartridgeSessionAccount } from "@cartridge/account-wasm/session";
|
|
2
|
+
import { Account, RpcProvider, } from "starknet";
|
|
3
|
+
import { SessionSigner } from "./signer";
|
|
4
|
+
import { normalizeCalls } from "./utils";
|
|
5
|
+
export * from "./errors";
|
|
6
|
+
export * from "./types";
|
|
7
|
+
export { defaultPresets } from "./presets";
|
|
8
|
+
export default class SessionAccount extends Account {
|
|
9
|
+
constructor({ rpcUrl, privateKey, address, ownerGuid, chainId, expiresAt, policies, }) {
|
|
10
|
+
const controller = CartridgeSessionAccount.new_as_registered(rpcUrl, privateKey, address, ownerGuid, chainId, {
|
|
11
|
+
expiresAt,
|
|
12
|
+
policies,
|
|
13
|
+
});
|
|
14
|
+
super(new RpcProvider({ nodeUrl: rpcUrl }), address, new SessionSigner(controller));
|
|
15
|
+
this.controller = controller;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Invoke execute function in account contract
|
|
19
|
+
*
|
|
20
|
+
* @param calls the invocation object or an array of them, containing:
|
|
21
|
+
* - contractAddress - the address of the contract
|
|
22
|
+
* - entrypoint - the entrypoint of the contract
|
|
23
|
+
* - calldata - (defaults to []) the calldata
|
|
24
|
+
* - signature - (defaults to []) the signature
|
|
25
|
+
* @param abis (optional) the abi of the contract for better displaying
|
|
26
|
+
*
|
|
27
|
+
* @returns response from addTransaction
|
|
28
|
+
*/
|
|
29
|
+
async execute(calls, _abisOrDetails, _transactionsDetail) {
|
|
30
|
+
return this.controller.execute(normalizeCalls(calls));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
34
|
+
* This adds a message prefix so it cant be interchanged with transactions
|
|
35
|
+
*
|
|
36
|
+
* @param json - JSON object to be signed
|
|
37
|
+
* @returns the signature of the JSON object
|
|
38
|
+
* @throws {Error} if the JSON object is not a valid JSON
|
|
39
|
+
*/
|
|
40
|
+
async signMessage(_typedData) {
|
|
41
|
+
throw new Error("signMessage not implemented for SessionSigner");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAEL,OAAO,EAGP,WAAW,GAIZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAGjD,YAAY,EACV,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,GAST;QACC,MAAM,UAAU,GAAG,uBAAuB,CAAC,iBAAiB,CAC1D,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAAO,EACP;YACE,SAAS;YACT,QAAQ;SACT,CACF,CAAC;QAEF,KAAK,CACH,IAAI,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EACpC,OAAO,EACP,IAAI,aAAa,CAAC,UAAU,CAAC,CAC9B,CAAC;QAEF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,OAAO,CACX,KAAoB,EACpB,cAAyC,EACzC,mBAAsC;QAEtC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,UAAqB;QACrC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;CACF"}
|
package/dist/signer.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Abi, Call, DeclareSignerDetails, DeployAccountSignerDetails, InvocationsSignerDetails, Signature, SignerInterface, TypedData } from "starknet";
|
|
1
|
+
import { Abi, BigNumberish, Call, DeclareSignerDetails, DeployAccountSignerDetails, InvocationsSignerDetails, Signature, SignerInterface, TypedData } from "starknet";
|
|
2
2
|
import { Keychain, Modal } from "./types";
|
|
3
3
|
import { AsyncMethodReturns } from "@cartridge/penpal";
|
|
4
|
+
import { CartridgeSessionAccount } from "@cartridge/account-wasm/session";
|
|
4
5
|
export declare class Signer implements SignerInterface {
|
|
5
6
|
private keychain;
|
|
6
7
|
modal: Modal;
|
|
@@ -25,3 +26,28 @@ export declare class Signer implements SignerInterface {
|
|
|
25
26
|
signDeployAccountTransaction(transaction: DeployAccountSignerDetails): Promise<Signature>;
|
|
26
27
|
signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
|
|
27
28
|
}
|
|
29
|
+
export declare class SessionSigner implements SignerInterface {
|
|
30
|
+
controller: CartridgeSessionAccount;
|
|
31
|
+
constructor(controller: CartridgeSessionAccount);
|
|
32
|
+
/**
|
|
33
|
+
* Method to get the public key of the signer
|
|
34
|
+
*
|
|
35
|
+
* @returns public key of signer as hex string with 0x prefix
|
|
36
|
+
*/
|
|
37
|
+
getPubKey(): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
40
|
+
* This adds a message prefix so it cant be interchanged with transactions
|
|
41
|
+
*
|
|
42
|
+
* @param typedData - JSON object to be signed
|
|
43
|
+
* @param accountAddress - account
|
|
44
|
+
* @returns the signature of the JSON object
|
|
45
|
+
* @throws {Error} if the JSON object is not a valid JSON
|
|
46
|
+
*/
|
|
47
|
+
signMessage(_typedData: TypedData, _account: string): Promise<Signature>;
|
|
48
|
+
signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails & {
|
|
49
|
+
maxFee: BigNumberish;
|
|
50
|
+
}, _abis?: Abi[]): Promise<Signature>;
|
|
51
|
+
signDeployAccountTransaction(_transaction: DeployAccountSignerDetails): Promise<Signature>;
|
|
52
|
+
signDeclareTransaction(_transaction: DeclareSignerDetails): Promise<Signature>;
|
|
53
|
+
}
|
package/dist/signer.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeCalls } from "./utils";
|
|
1
2
|
export class Signer {
|
|
2
3
|
constructor(keychain, modal) {
|
|
3
4
|
this.keychain = keychain;
|
|
@@ -45,4 +46,38 @@ export class Signer {
|
|
|
45
46
|
return res;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
export class SessionSigner {
|
|
50
|
+
constructor(controller) {
|
|
51
|
+
this.controller = controller;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Method to get the public key of the signer
|
|
55
|
+
*
|
|
56
|
+
* @returns public key of signer as hex string with 0x prefix
|
|
57
|
+
*/
|
|
58
|
+
getPubKey() {
|
|
59
|
+
return Promise.resolve("");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
63
|
+
* This adds a message prefix so it cant be interchanged with transactions
|
|
64
|
+
*
|
|
65
|
+
* @param typedData - JSON object to be signed
|
|
66
|
+
* @param accountAddress - account
|
|
67
|
+
* @returns the signature of the JSON object
|
|
68
|
+
* @throws {Error} if the JSON object is not a valid JSON
|
|
69
|
+
*/
|
|
70
|
+
async signMessage(_typedData, _account) {
|
|
71
|
+
throw new Error("signMessage not implemented for SessionSigner");
|
|
72
|
+
}
|
|
73
|
+
async signTransaction(transactions, transactionsDetail, _abis) {
|
|
74
|
+
return this.controller.sign_transaction(normalizeCalls(transactions), transactionsDetail.maxFee);
|
|
75
|
+
}
|
|
76
|
+
async signDeployAccountTransaction(_transaction) {
|
|
77
|
+
throw new Error("signDeployAccountTransaction not implemented for SessionSigner");
|
|
78
|
+
}
|
|
79
|
+
async signDeclareTransaction(_transaction) {
|
|
80
|
+
throw new Error("signDeclareTransaction not implemented for SessionSigner");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
48
83
|
//# sourceMappingURL=signer.js.map
|
package/dist/signer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,OAAO,MAAM;IAGjB,YAAY,QAAsC,EAAE,KAAY;QAC9D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,SAAS;QACd,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,WAAW,CAC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CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,WAAW,CACtB,UAAqB,EACrB,QAAgB;QAEhB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAEM,KAAK,CAAC,eAAe,CAC1B,YAAoB,EACpB,kBAAuE,EACvE,KAAa;QAEb,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,CACrC,cAAc,CAAC,YAAY,CAAC,EAC5B,kBAAkB,CAAC,MAAM,CAC1B,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,4BAA4B,CACvC,YAAwC;QAExC,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,sBAAsB,CACjC,YAAkC;QAElC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { constants, Abi, Call, InvocationsDetails, TypedData, InvokeFunctionResponse, Signature, EstimateFeeDetails, EstimateFee, DeclareContractPayload, BigNumberish, InvocationsSignerDetails, DeployAccountSignerDetails, DeclareSignerDetails } from "starknet";
|
|
2
2
|
import { KeychainIFrame, ProfileIFrame } from "./iframe";
|
|
3
|
-
import wasm from "@cartridge/account-wasm";
|
|
3
|
+
import wasm from "@cartridge/account-wasm/controller";
|
|
4
4
|
export type Session = {
|
|
5
5
|
chainId: constants.StarknetChainId;
|
|
6
6
|
policies: Policy[];
|
|
@@ -53,8 +53,11 @@ export type IFrames = {
|
|
|
53
53
|
keychain: KeychainIFrame;
|
|
54
54
|
profile?: ProfileIFrame;
|
|
55
55
|
};
|
|
56
|
+
type ContractAddress = string;
|
|
57
|
+
type CartridgeID = string;
|
|
58
|
+
export type ControllerAccounts = Record<ContractAddress, CartridgeID>;
|
|
56
59
|
export interface Keychain {
|
|
57
|
-
probe(rpcUrl
|
|
60
|
+
probe(rpcUrl: string): Promise<ProbeReply | ConnectError>;
|
|
58
61
|
connect(policies: Policy[], rpcUrl: string): Promise<ConnectReply | ConnectError>;
|
|
59
62
|
disconnect(): void;
|
|
60
63
|
reset(): void;
|
|
@@ -73,11 +76,12 @@ export interface Keychain {
|
|
|
73
76
|
signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
|
|
74
77
|
signDeployAccountTransaction(transaction: DeployAccountSignerDetails): Promise<Signature>;
|
|
75
78
|
signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
|
|
76
|
-
username(): string;
|
|
77
79
|
delegateAccount(): string;
|
|
80
|
+
username(): string;
|
|
81
|
+
fetchControllers(contractAddresses: string[]): Promise<ControllerAccounts>;
|
|
78
82
|
}
|
|
79
83
|
export interface Profile {
|
|
80
|
-
|
|
84
|
+
navigate(tab: ProfileContextTypeVariant): void;
|
|
81
85
|
}
|
|
82
86
|
export interface Modal {
|
|
83
87
|
open: () => void;
|
|
@@ -87,6 +91,9 @@ export interface Modal {
|
|
|
87
91
|
* Options for configuring the controller
|
|
88
92
|
*/
|
|
89
93
|
export type ControllerOptions = KeychainOptions & ProfileOptions;
|
|
94
|
+
export type TokenOptions = {
|
|
95
|
+
tokens: Tokens;
|
|
96
|
+
};
|
|
90
97
|
export type IFrameOptions = {
|
|
91
98
|
/** The ID of the starter pack to use */
|
|
92
99
|
starterPackId?: string;
|
|
@@ -118,6 +125,8 @@ export type ProfileOptions = IFrameOptions & {
|
|
|
118
125
|
profileUrl?: string;
|
|
119
126
|
/** The URL of Torii indexer. Will be mandatory once profile page is in production */
|
|
120
127
|
indexerUrl?: string;
|
|
128
|
+
/** The tokens to be listed on Inventory modal */
|
|
129
|
+
tokens?: Tokens;
|
|
121
130
|
};
|
|
122
131
|
export type ProfileContextTypeVariant = "quest" | "inventory" | "history";
|
|
123
132
|
/**
|
|
@@ -159,3 +168,11 @@ export type Prefund = {
|
|
|
159
168
|
address: string;
|
|
160
169
|
min: string;
|
|
161
170
|
};
|
|
171
|
+
export type Tokens = {
|
|
172
|
+
erc20?: ERC20[];
|
|
173
|
+
};
|
|
174
|
+
export type ERC20 = {
|
|
175
|
+
address: string;
|
|
176
|
+
logoUrl?: string;
|
|
177
|
+
};
|
|
178
|
+
export {};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { Policy } from "./types";
|
|
2
|
+
import { Call } from "starknet";
|
|
2
3
|
export declare function diff(a: Policy[], b: Policy[]): Policy[];
|
|
3
|
-
export declare
|
|
4
|
+
export declare function normalizeCalls(calls: Call | Call[]): {
|
|
5
|
+
entrypoint: string;
|
|
6
|
+
contractAddress: string;
|
|
7
|
+
calldata: import("starknet").HexCalldata;
|
|
8
|
+
}[];
|
package/dist/utils.js
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
import equal from "fast-deep-equal";
|
|
2
|
-
import { addAddressPadding } from "starknet";
|
|
2
|
+
import { addAddressPadding, CallData } from "starknet";
|
|
3
3
|
export function diff(a, b) {
|
|
4
4
|
return a.reduce((prev, policyA) => b.some((policyB) => equal(policyB, policyA)) ? prev : [...prev, policyA], []);
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
method: "POST",
|
|
16
|
-
mode: "cors",
|
|
17
|
-
credentials: "omit",
|
|
18
|
-
})).json();
|
|
19
|
-
if (res.errors) {
|
|
20
|
-
throw new Error(res.errors[0].message);
|
|
21
|
-
}
|
|
22
|
-
return res.accounts.edges.map((edge) => ({
|
|
23
|
-
id: edge.node.id,
|
|
24
|
-
name: edge.node.id,
|
|
25
|
-
profile_uri: `https://cartridge.gg/profile/${edge.node.contractAddress}`,
|
|
26
|
-
}));
|
|
27
|
-
};
|
|
6
|
+
export function normalizeCalls(calls) {
|
|
7
|
+
return (Array.isArray(calls) ? calls : [calls]).map((call) => {
|
|
8
|
+
return {
|
|
9
|
+
entrypoint: call.entrypoint,
|
|
10
|
+
contractAddress: addAddressPadding(call.contractAddress),
|
|
11
|
+
calldata: CallData.toHex(call.calldata),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
28
15
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAQ,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7D,MAAM,UAAU,IAAI,CAAC,CAAW,EAAE,CAAW;IAC3C,OAAO,CAAC,CAAC,MAAM,CACb,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAChB,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,EAC1E,EAAc,CACf,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAoB;IACjD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3D,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,eAAe,EAAE,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC;YACxD,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;SACxC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartridge/controller",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Cartridge Controller",
|
|
5
|
-
"module": "dist/
|
|
6
|
-
"types": "dist/
|
|
5
|
+
"module": "dist/controller.js",
|
|
6
|
+
"types": "dist/controller.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"
|
|
9
|
-
"dist"
|
|
10
|
-
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/controller.js",
|
|
10
|
+
"./session": "./dist/session.js"
|
|
11
|
+
},
|
|
12
|
+
"typesVersions": {
|
|
13
|
+
"*": {
|
|
14
|
+
".": [
|
|
15
|
+
"./dist/controller.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"session": [
|
|
18
|
+
"./dist/session.d.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
11
22
|
"dependencies": {
|
|
12
23
|
"@cartridge/penpal": "^6.2.3",
|
|
13
24
|
"base64url": "^3.0.1",
|
|
@@ -15,12 +26,12 @@
|
|
|
15
26
|
"fast-deep-equal": "^3.1.3",
|
|
16
27
|
"query-string": "^7.1.1",
|
|
17
28
|
"starknet": "^6.11.0",
|
|
18
|
-
"@cartridge/account-wasm": "^0.
|
|
29
|
+
"@cartridge/account-wasm": "^0.4.0"
|
|
19
30
|
},
|
|
20
31
|
"devDependencies": {
|
|
21
32
|
"@types/node": "^20.6.0",
|
|
22
33
|
"typescript": "^5.4.5",
|
|
23
|
-
"@cartridge/tsconfig": "^0.
|
|
34
|
+
"@cartridge/tsconfig": "^0.4.0"
|
|
24
35
|
},
|
|
25
36
|
"scripts": {
|
|
26
37
|
"build:deps": "tsc",
|
package/src/constants.ts
ADDED