@cartridge/controller 0.5.0-alpha.4 → 0.5.0-alpha.6
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 +116 -4
- package/dist/account.d.ts +9 -6
- package/dist/account.js +84 -74
- package/dist/account.js.map +1 -1
- package/dist/constants.d.ts +4 -2
- package/dist/constants.js +7 -2
- package/dist/constants.js.map +1 -1
- package/dist/controller.d.ts +12 -5
- package/dist/controller.js +739 -182
- package/dist/controller.js.map +1 -1
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +10 -6
- package/dist/errors.js.map +1 -1
- package/dist/icon.d.ts +3 -1
- package/dist/icon.js +5 -1
- package/dist/icon.js.map +1 -1
- package/dist/iframe/base.d.ts +5 -23
- package/dist/iframe/base.js +272 -98
- package/dist/iframe/base.js.map +1 -1
- package/dist/iframe/index.d.ts +5 -3
- package/dist/iframe/index.js +331 -3
- package/dist/iframe/index.js.map +1 -1
- package/dist/iframe/keychain.d.ts +5 -7
- package/dist/iframe/keychain.js +294 -13
- package/dist/iframe/keychain.js.map +1 -1
- package/dist/iframe/profile.d.ts +5 -11
- package/dist/iframe/profile.js +308 -16
- package/dist/iframe/profile.js.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.js +767 -4
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +9 -2
- package/dist/presets.js +159 -146
- package/dist/presets.js.map +1 -1
- package/dist/provider.d.ts +9 -4
- package/dist/provider.js +138 -124
- package/dist/provider.js.map +1 -1
- package/dist/session/account.d.ts +14 -8
- package/dist/session/account.js +235 -27
- package/dist/session/account.js.map +1 -1
- package/dist/session/backend.d.ts +4 -2
- package/dist/session/backend.js +38 -37
- package/dist/session/backend.js.map +1 -1
- package/dist/session/index.d.ts +9 -5
- package/dist/session/index.js +467 -5
- package/dist/session/index.js.map +1 -1
- package/dist/session/provider.d.ts +12 -8
- package/dist/session/provider.js +281 -81
- package/dist/session/provider.js.map +1 -1
- package/dist/telegram/backend.d.ts +5 -2
- package/dist/telegram/backend.js +38 -37
- package/dist/telegram/backend.js.map +1 -1
- package/dist/telegram/provider.d.ts +7 -4
- package/dist/telegram/provider.js +283 -70
- package/dist/telegram/provider.js.map +1 -1
- package/dist/types-DIeWpu0p.d.ts +196 -0
- package/dist/types.d.ts +5 -159
- package/dist/types.js +12 -8
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +7 -3
- package/dist/utils.js +12 -8
- package/dist/utils.js.map +1 -1
- package/package.json +17 -14
- package/src/controller.ts +13 -25
- package/src/iframe/base.ts +3 -0
- package/src/iframe/profile.ts +17 -9
- package/src/presets.ts +10 -1
- package/src/session/provider.ts +1 -2
- package/src/types.ts +3 -7
- package/tsconfig.json +4 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,4 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @cartridge/controller@0.5.0-alpha.6 build:deps /home/broody/development/controller/packages/controller
|
|
4
|
+
> tsup --dts-resolve
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: src/account.ts, src/constants.ts, src/controller.ts, src/errors.ts, src/icon.ts, src/index.ts, src/presets.ts, src/provider.ts, src/types.ts, src/utils.ts, src/telegram/backend.ts, src/telegram/provider.ts, src/iframe/base.ts, src/iframe/index.ts, src/iframe/keychain.ts, src/iframe/profile.ts, src/session/account.ts, src/session/backend.ts, src/session/index.ts, src/session/provider.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.3.0
|
|
9
|
+
[34mCLI[39m Using tsup config: /home/broody/development/controller/packages/controller/package.json
|
|
10
|
+
[34mCLI[39m Target: es2020
|
|
11
|
+
[34mCLI[39m Cleaning output folder
|
|
12
|
+
[34mESM[39m Build start
|
|
13
|
+
[32mESM[39m [1mdist/account.js [22m[32m2.39 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/controller.js [22m[32m35.01 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/errors.js [22m[32m271.00 B[39m
|
|
16
|
+
[32mESM[39m [1mdist/constants.js [22m[32m194.00 B[39m
|
|
17
|
+
[32mESM[39m [1mdist/provider.js [22m[32m19.16 KB[39m
|
|
18
|
+
[32mESM[39m [1mdist/types.js [22m[32m437.00 B[39m
|
|
19
|
+
[32mESM[39m [1mdist/telegram/backend.js [22m[32m1.27 KB[39m
|
|
20
|
+
[32mESM[39m [1mdist/utils.js [22m[32m406.00 B[39m
|
|
21
|
+
[32mESM[39m [1mdist/telegram/provider.js [22m[32m23.14 KB[39m
|
|
22
|
+
[32mESM[39m [1mdist/iframe/base.js [22m[32m7.01 KB[39m
|
|
23
|
+
[32mESM[39m [1mdist/iframe/index.js [22m[32m8.33 KB[39m
|
|
24
|
+
[32mESM[39m [1mdist/iframe/keychain.js [22m[32m7.49 KB[39m
|
|
25
|
+
[32mESM[39m [1mdist/index.js [22m[32m35.44 KB[39m
|
|
26
|
+
[32mESM[39m [1mdist/iframe/profile.js [22m[32m7.87 KB[39m
|
|
27
|
+
[32mESM[39m [1mdist/session/account.js [22m[32m5.64 KB[39m
|
|
28
|
+
[32mESM[39m [1mdist/icon.js [22m[32m15.15 KB[39m
|
|
29
|
+
[32mESM[39m [1mdist/session/backend.js [22m[32m1.18 KB[39m
|
|
30
|
+
[32mESM[39m [1mdist/presets.js [22m[32m3.54 KB[39m
|
|
31
|
+
[32mESM[39m [1mdist/session/index.js [22m[32m27.68 KB[39m
|
|
32
|
+
[32mESM[39m [1mdist/session/provider.js [22m[32m23.58 KB[39m
|
|
33
|
+
[32mESM[39m [1mdist/account.js.map [22m[32m4.58 KB[39m
|
|
34
|
+
[32mESM[39m [1mdist/constants.js.map [22m[32m245.00 B[39m
|
|
35
|
+
[32mESM[39m [1mdist/errors.js.map [22m[32m385.00 B[39m
|
|
36
|
+
[32mESM[39m [1mdist/controller.js.map [22m[32m53.28 KB[39m
|
|
37
|
+
[32mESM[39m [1mdist/types.js.map [22m[32m5.09 KB[39m
|
|
38
|
+
[32mESM[39m [1mdist/telegram/backend.js.map [22m[32m1.98 KB[39m
|
|
39
|
+
[32mESM[39m [1mdist/provider.js.map [22m[32m22.49 KB[39m
|
|
40
|
+
[32mESM[39m [1mdist/utils.js.map [22m[32m707.00 B[39m
|
|
41
|
+
[32mESM[39m [1mdist/telegram/provider.js.map [22m[32m30.45 KB[39m
|
|
42
|
+
[32mESM[39m [1mdist/iframe/index.js.map [22m[32m15.86 KB[39m
|
|
43
|
+
[32mESM[39m [1mdist/iframe/keychain.js.map [22m[32m14.05 KB[39m
|
|
44
|
+
[32mESM[39m [1mdist/iframe/base.js.map [22m[32m12.91 KB[39m
|
|
45
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m58.31 KB[39m
|
|
46
|
+
[32mESM[39m [1mdist/iframe/profile.js.map [22m[32m14.86 KB[39m
|
|
47
|
+
[32mESM[39m [1mdist/session/account.js.map [22m[32m14.35 KB[39m
|
|
48
|
+
[32mESM[39m [1mdist/icon.js.map [22m[32m15.20 KB[39m
|
|
49
|
+
[32mESM[39m [1mdist/session/backend.js.map [22m[32m2.88 KB[39m
|
|
50
|
+
[32mESM[39m [1mdist/session/index.js.map [22m[32m42.69 KB[39m
|
|
51
|
+
[32mESM[39m [1mdist/session/provider.js.map [22m[32m31.27 KB[39m
|
|
52
|
+
[32mESM[39m [1mdist/presets.js.map [22m[32m6.14 KB[39m
|
|
53
|
+
[32mESM[39m ⚡️ Build success in 38ms
|
|
54
|
+
[34mDTS[39m Build start
|
|
55
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
56
|
+
|
|
57
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
58
|
+
|
|
59
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
60
|
+
|
|
61
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
62
|
+
|
|
63
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
64
|
+
|
|
65
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
66
|
+
|
|
67
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
68
|
+
|
|
69
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
70
|
+
|
|
71
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
72
|
+
|
|
73
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
74
|
+
|
|
75
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
76
|
+
|
|
77
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
78
|
+
|
|
79
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
80
|
+
|
|
81
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
82
|
+
|
|
83
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
84
|
+
|
|
85
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
86
|
+
|
|
87
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
88
|
+
|
|
89
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
90
|
+
|
|
91
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
92
|
+
|
|
93
|
+
../tsconfig/base.json(6,25): error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.
|
|
94
|
+
|
|
95
|
+
[32mDTS[39m ⚡️ Build success in 4588ms
|
|
96
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m891.00 B[39m
|
|
97
|
+
[32mDTS[39m [1mdist/session/index.d.ts [22m[32m909.00 B[39m
|
|
98
|
+
[32mDTS[39m [1mdist/account.d.ts [22m[32m1.64 KB[39m
|
|
99
|
+
[32mDTS[39m [1mdist/constants.d.ts [22m[32m154.00 B[39m
|
|
100
|
+
[32mDTS[39m [1mdist/icon.d.ts [22m[32m15.11 KB[39m
|
|
101
|
+
[32mDTS[39m [1mdist/controller.d.ts [22m[32m1.05 KB[39m
|
|
102
|
+
[32mDTS[39m [1mdist/utils.d.ts [22m[32m251.00 B[39m
|
|
103
|
+
[32mDTS[39m [1mdist/telegram/backend.d.ts [22m[32m1.27 KB[39m
|
|
104
|
+
[32mDTS[39m [1mdist/telegram/provider.d.ts [22m[32m706.00 B[39m
|
|
105
|
+
[32mDTS[39m [1mdist/session/account.d.ts [22m[32m2.00 KB[39m
|
|
106
|
+
[32mDTS[39m [1mdist/session/backend.d.ts [22m[32m2.29 KB[39m
|
|
107
|
+
[32mDTS[39m [1mdist/errors.d.ts [22m[32m100.00 B[39m
|
|
108
|
+
[32mDTS[39m [1mdist/presets.d.ts [22m[32m274.00 B[39m
|
|
109
|
+
[32mDTS[39m [1mdist/session/provider.d.ts [22m[32m969.00 B[39m
|
|
110
|
+
[32mDTS[39m [1mdist/provider.d.ts [22m[32m788.00 B[39m
|
|
111
|
+
[32mDTS[39m [1mdist/iframe/base.d.ts [22m[32m196.00 B[39m
|
|
112
|
+
[32mDTS[39m [1mdist/iframe/keychain.d.ts [22m[32m184.00 B[39m
|
|
113
|
+
[32mDTS[39m [1mdist/iframe/profile.d.ts [22m[32m210.00 B[39m
|
|
114
|
+
[32mDTS[39m [1mdist/iframe/index.d.ts [22m[32m264.00 B[39m
|
|
115
|
+
[32mDTS[39m [1mdist/types.d.ts [22m[32m728.00 B[39m
|
|
116
|
+
[32mDTS[39m [1mdist/types-DIeWpu0p.d.ts [22m[32m6.59 KB[39m
|
package/dist/account.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SPEC } from
|
|
3
|
-
import { Keychain, KeychainOptions, Modal } from
|
|
4
|
-
import { AsyncMethodReturns } from
|
|
5
|
-
import BaseProvider from
|
|
1
|
+
import { WalletAccount, AllowArray, Call, InvokeFunctionResponse, TypedData } from 'starknet';
|
|
2
|
+
import { SPEC } from '@starknet-io/types-js';
|
|
3
|
+
import { K as Keychain, i as KeychainOptions, M as Modal } from './types-DIeWpu0p.js';
|
|
4
|
+
import { AsyncMethodReturns } from '@cartridge/penpal';
|
|
5
|
+
import BaseProvider from './provider.js';
|
|
6
|
+
import '@cartridge/account-wasm/controller';
|
|
7
|
+
|
|
6
8
|
declare class ControllerAccount extends WalletAccount {
|
|
7
9
|
address: string;
|
|
8
10
|
private keychain;
|
|
@@ -32,4 +34,5 @@ declare class ControllerAccount extends WalletAccount {
|
|
|
32
34
|
*/
|
|
33
35
|
signMessage(typedData: TypedData): Promise<SPEC.SIGNATURE>;
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
|
|
38
|
+
export { ControllerAccount as default };
|
package/dist/account.js
CHANGED
|
@@ -1,76 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
// src/account.ts
|
|
2
|
+
import {
|
|
3
|
+
WalletAccount
|
|
4
|
+
} from "starknet";
|
|
5
|
+
var ControllerAccount = class extends WalletAccount {
|
|
6
|
+
constructor(provider, address, keychain, options, modal) {
|
|
7
|
+
super({ nodeUrl: provider.rpc.toString() }, provider);
|
|
8
|
+
this.address = address;
|
|
9
|
+
this.keychain = keychain;
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.modal = modal;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Invoke execute function in account contract
|
|
15
|
+
*
|
|
16
|
+
* @param calls the invocation object or an array of them, containing:
|
|
17
|
+
* - contractAddress - the address of the contract
|
|
18
|
+
* - entrypoint - the entrypoint of the contract
|
|
19
|
+
* - calldata - (defaults to []) the calldata
|
|
20
|
+
* - signature - (defaults to []) the signature
|
|
21
|
+
* @param abis (optional) the abi of the contract for better displaying
|
|
22
|
+
*
|
|
23
|
+
* @returns response from addTransaction
|
|
24
|
+
*/
|
|
25
|
+
async execute(calls) {
|
|
26
|
+
calls = Array.isArray(calls) ? calls : [calls];
|
|
27
|
+
return new Promise(async (resolve, reject) => {
|
|
28
|
+
const sessionExecute = await this.keychain.execute(
|
|
29
|
+
calls,
|
|
30
|
+
void 0,
|
|
31
|
+
void 0,
|
|
32
|
+
false
|
|
33
|
+
);
|
|
34
|
+
if (sessionExecute.code === "SUCCESS" /* SUCCESS */) {
|
|
35
|
+
resolve(sessionExecute);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (this.options?.propagateSessionErrors) {
|
|
39
|
+
reject(sessionExecute.error);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.modal.open();
|
|
43
|
+
const manualExecute = await this.keychain.execute(
|
|
44
|
+
calls,
|
|
45
|
+
void 0,
|
|
46
|
+
void 0,
|
|
47
|
+
true,
|
|
48
|
+
sessionExecute.error
|
|
49
|
+
);
|
|
50
|
+
if (manualExecute.code === "SUCCESS" /* SUCCESS */) {
|
|
51
|
+
resolve(manualExecute);
|
|
52
|
+
this.modal.close();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
reject(manualExecute.error);
|
|
56
|
+
return;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
61
|
+
* This adds a message prefix so it cant be interchanged with transactions
|
|
62
|
+
*
|
|
63
|
+
* @param json - JSON object to be signed
|
|
64
|
+
* @returns the signature of the JSON object
|
|
65
|
+
* @throws {Error} if the JSON object is not a valid JSON
|
|
66
|
+
*/
|
|
67
|
+
async signMessage(typedData) {
|
|
68
|
+
try {
|
|
69
|
+
this.modal.open();
|
|
70
|
+
const res = await this.keychain.signMessage(typedData, "");
|
|
71
|
+
this.modal.close();
|
|
72
|
+
if ("code" in res) {
|
|
73
|
+
throw res;
|
|
74
|
+
}
|
|
75
|
+
return res;
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.error(e);
|
|
78
|
+
throw e;
|
|
10
79
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* - calldata - (defaults to []) the calldata
|
|
18
|
-
* - signature - (defaults to []) the signature
|
|
19
|
-
* @param abis (optional) the abi of the contract for better displaying
|
|
20
|
-
*
|
|
21
|
-
* @returns response from addTransaction
|
|
22
|
-
*/
|
|
23
|
-
async execute(calls) {
|
|
24
|
-
calls = Array.isArray(calls) ? calls : [calls];
|
|
25
|
-
return new Promise(async (resolve, reject) => {
|
|
26
|
-
const sessionExecute = await this.keychain.execute(calls, undefined, undefined, false);
|
|
27
|
-
// Session call succeeded
|
|
28
|
-
if (sessionExecute.code === ResponseCodes.SUCCESS) {
|
|
29
|
-
resolve(sessionExecute);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// Propagates session txn error back to caller
|
|
33
|
-
if (this.options?.propagateSessionErrors) {
|
|
34
|
-
reject(sessionExecute.error);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// Session call or Paymaster flow failed.
|
|
38
|
-
// Session not avaialble, manual flow fallback
|
|
39
|
-
this.modal.open();
|
|
40
|
-
const manualExecute = await this.keychain.execute(calls, undefined, undefined, true, sessionExecute.error);
|
|
41
|
-
// Manual call succeeded
|
|
42
|
-
if (manualExecute.code === ResponseCodes.SUCCESS) {
|
|
43
|
-
resolve(manualExecute);
|
|
44
|
-
this.modal.close();
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
reject(manualExecute.error);
|
|
48
|
-
return;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
53
|
-
* This adds a message prefix so it cant be interchanged with transactions
|
|
54
|
-
*
|
|
55
|
-
* @param json - JSON object to be signed
|
|
56
|
-
* @returns the signature of the JSON object
|
|
57
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
58
|
-
*/
|
|
59
|
-
async signMessage(typedData) {
|
|
60
|
-
try {
|
|
61
|
-
this.modal.open();
|
|
62
|
-
const res = await this.keychain.signMessage(typedData, "");
|
|
63
|
-
this.modal.close();
|
|
64
|
-
if ("code" in res) {
|
|
65
|
-
throw res;
|
|
66
|
-
}
|
|
67
|
-
return res;
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
console.error(e);
|
|
71
|
-
throw e;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export default ControllerAccount;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var account_default = ControllerAccount;
|
|
83
|
+
export {
|
|
84
|
+
account_default as default
|
|
85
|
+
};
|
|
76
86
|
//# sourceMappingURL=account.js.map
|
package/dist/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/account.ts"],"sourcesContent":["import {\n InvokeFunctionResponse,\n TypedData,\n WalletAccount,\n Call,\n AllowArray,\n} from \"starknet\";\n\nimport { SPEC } from \"@starknet-io/types-js\";\n\nimport {\n ConnectError,\n Keychain,\n KeychainOptions,\n Modal,\n ResponseCodes,\n} from \"./types\";\nimport { AsyncMethodReturns } from \"@cartridge/penpal\";\nimport BaseProvider from \"./provider\";\n\nclass ControllerAccount extends WalletAccount {\n address: string;\n private keychain: AsyncMethodReturns<Keychain>;\n private modal: Modal;\n private options?: KeychainOptions;\n\n constructor(\n provider: BaseProvider,\n address: string,\n keychain: AsyncMethodReturns<Keychain>,\n options: KeychainOptions,\n modal: Modal,\n ) {\n super({ nodeUrl: provider.rpc.toString() }, provider);\n\n this.address = address;\n this.keychain = keychain;\n this.options = options;\n this.modal = modal;\n }\n\n /**\n * Invoke execute function in account contract\n *\n * @param calls the invocation object or an array of them, containing:\n * - contractAddress - the address of the contract\n * - entrypoint - the entrypoint of the contract\n * - calldata - (defaults to []) the calldata\n * - signature - (defaults to []) the signature\n * @param abis (optional) the abi of the contract for better displaying\n *\n * @returns response from addTransaction\n */\n async execute(calls: AllowArray<Call>): Promise<InvokeFunctionResponse> {\n calls = Array.isArray(calls) ? calls : [calls];\n\n return new Promise(async (resolve, reject) => {\n const sessionExecute = await this.keychain.execute(\n calls,\n undefined,\n undefined,\n false,\n );\n\n // Session call succeeded\n if (sessionExecute.code === ResponseCodes.SUCCESS) {\n resolve(sessionExecute as InvokeFunctionResponse);\n return;\n }\n\n // Propagates session txn error back to caller\n if (this.options?.propagateSessionErrors) {\n reject((sessionExecute as ConnectError).error);\n return;\n }\n\n // Session call or Paymaster flow failed.\n // Session not avaialble, manual flow fallback\n this.modal.open();\n const manualExecute = await this.keychain.execute(\n calls,\n undefined,\n undefined,\n true,\n (sessionExecute as ConnectError).error,\n );\n\n // Manual call succeeded\n if (manualExecute.code === ResponseCodes.SUCCESS) {\n resolve(manualExecute as InvokeFunctionResponse);\n this.modal.close();\n return;\n }\n\n reject((manualExecute as ConnectError).error);\n return;\n });\n }\n\n /**\n * Sign an JSON object for off-chain usage with the starknet private key and return the signature\n * This adds a message prefix so it cant be interchanged with transactions\n *\n * @param json - JSON object to be signed\n * @returns the signature of the JSON object\n * @throws {Error} if the JSON object is not a valid JSON\n */\n async signMessage(typedData: TypedData): Promise<SPEC.SIGNATURE> {\n try {\n this.modal.open();\n const res = await this.keychain.signMessage(typedData, \"\");\n this.modal.close();\n\n if (\"code\" in res) {\n throw res;\n }\n\n return res;\n } catch (e) {\n console.error(e);\n throw e;\n }\n }\n}\n\nexport default ControllerAccount;\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,OAGK;AAcP,IAAM,oBAAN,cAAgC,cAAc;AAAA,EAM5C,YACE,UACA,SACA,UACA,SACA,OACA;AACA,UAAM,EAAE,SAAS,SAAS,IAAI,SAAS,EAAE,GAAG,QAAQ;AAEpD,SAAK,UAAU;AACf,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,QAAQ;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,QAAQ,OAA0D;AACtE,YAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAE7C,WAAO,IAAI,QAAQ,OAAO,SAAS,WAAW;AAC5C,YAAM,iBAAiB,MAAM,KAAK,SAAS;AAAA,QACzC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAGA,UAAI,eAAe,kCAAgC;AACjD,gBAAQ,cAAwC;AAChD;AAAA,MACF;AAGA,UAAI,KAAK,SAAS,wBAAwB;AACxC,eAAQ,eAAgC,KAAK;AAC7C;AAAA,MACF;AAIA,WAAK,MAAM,KAAK;AAChB,YAAM,gBAAgB,MAAM,KAAK,SAAS;AAAA,QACxC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,eAAgC;AAAA,MACnC;AAGA,UAAI,cAAc,kCAAgC;AAChD,gBAAQ,aAAuC;AAC/C,aAAK,MAAM,MAAM;AACjB;AAAA,MACF;AAEA,aAAQ,cAA+B,KAAK;AAC5C;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,YAAY,WAA+C;AAC/D,QAAI;AACF,WAAK,MAAM,KAAK;AAChB,YAAM,MAAM,MAAM,KAAK,SAAS,YAAY,WAAW,EAAE;AACzD,WAAK,MAAM,MAAM;AAEjB,UAAI,UAAU,KAAK;AACjB,cAAM;AAAA,MACR;AAEA,aAAO;AAAA,IACT,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AACf,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAEA,IAAO,kBAAQ;","names":[]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const KEYCHAIN_URL = "https://x.cartridge.gg";
|
|
2
|
+
declare const PROFILE_URL = "https://profile.cartridge.gg";
|
|
3
|
+
|
|
4
|
+
export { KEYCHAIN_URL, PROFILE_URL };
|
package/dist/constants.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var KEYCHAIN_URL = "https://x.cartridge.gg";
|
|
3
|
+
var PROFILE_URL = "https://profile.cartridge.gg";
|
|
4
|
+
export {
|
|
5
|
+
KEYCHAIN_URL,
|
|
6
|
+
PROFILE_URL
|
|
7
|
+
};
|
|
3
8
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const KEYCHAIN_URL = \"https://x.cartridge.gg\";\nexport const PROFILE_URL = \"https://profile.cartridge.gg\";\n"],"mappings":";AAAO,IAAM,eAAe;AACrB,IAAM,cAAc;","names":[]}
|
package/dist/controller.d.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import BaseProvider from
|
|
3
|
-
|
|
1
|
+
import { f as ControllerOptions, k as ProfileContextTypeVariant, P as Policy } from './types-DIeWpu0p.js';
|
|
2
|
+
import BaseProvider from './provider.js';
|
|
3
|
+
import { WalletAccount } from 'starknet';
|
|
4
|
+
import '@starknet-io/types-js';
|
|
5
|
+
import '@cartridge/penpal';
|
|
6
|
+
import '@cartridge/account-wasm/controller';
|
|
7
|
+
|
|
8
|
+
declare class ControllerProvider extends BaseProvider {
|
|
4
9
|
private keychain?;
|
|
5
10
|
private profile?;
|
|
6
11
|
private options;
|
|
7
12
|
private iframes;
|
|
8
13
|
constructor(options: ControllerOptions);
|
|
9
|
-
probe(): Promise<
|
|
10
|
-
connect(): Promise<
|
|
14
|
+
probe(): Promise<WalletAccount | undefined>;
|
|
15
|
+
connect(): Promise<WalletAccount | undefined>;
|
|
11
16
|
disconnect(): Promise<void>;
|
|
12
17
|
openProfile(tab?: ProfileContextTypeVariant): Promise<void>;
|
|
13
18
|
openSettings(): Promise<boolean | null>;
|
|
@@ -18,3 +23,5 @@ export default class ControllerProvider extends BaseProvider {
|
|
|
18
23
|
delegateAccount(): Promise<string | null>;
|
|
19
24
|
private waitForKeychain;
|
|
20
25
|
}
|
|
26
|
+
|
|
27
|
+
export { ControllerProvider as default };
|