@cartridge/controller 0.7.8 → 0.7.9-alpha.1
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 +49 -59
- package/.turbo/turbo-build.log +45 -63
- package/dist/account.d.ts +35 -0
- package/dist/constants.d.ts +3 -0
- package/dist/controller.d.ts +3 -6
- package/dist/errors.d.ts +3 -0
- package/dist/icon.d.ts +1 -0
- package/dist/iframe/base.d.ts +26 -0
- package/dist/iframe/index.d.ts +3 -0
- package/dist/iframe/keychain.d.ts +10 -0
- package/dist/iframe/profile.d.ts +12 -0
- package/dist/index.d.ts +6 -67
- package/dist/index.js +1088 -1063
- package/dist/index.js.map +1 -1
- package/dist/lookup.d.ts +2 -4
- package/dist/mutex.d.ts +12 -0
- package/dist/node/index.cjs +1 -12
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +93 -8
- package/dist/node/index.d.ts +93 -8
- package/dist/node/index.js +2 -12
- package/dist/node/index.js.map +1 -1
- package/dist/policies.d.ts +15 -0
- package/dist/provider-qJi60GEX.js +286 -0
- package/dist/provider-qJi60GEX.js.map +1 -0
- package/dist/provider.d.ts +21 -0
- package/dist/session/account.d.ts +31 -0
- package/dist/session/backend.d.ts +58 -0
- package/dist/session/index.d.ts +4 -38
- package/dist/session/{index.d.cts → provider.d.ts} +4 -10
- package/dist/session.d.ts +6 -0
- package/dist/session.js +354 -0
- package/dist/session.js.map +1 -0
- package/dist/stats.html +4949 -0
- package/dist/telegram/backend.d.ts +30 -0
- package/dist/telegram/provider.d.ts +24 -0
- package/dist/types.d.ts +146 -0
- package/dist/utils.d.ts +15 -0
- package/dist/wallets/argent/index.d.ts +14 -0
- package/dist/wallets/bridge.d.ts +29 -0
- package/dist/wallets/index.d.ts +5 -0
- package/dist/wallets/metamask/index.d.ts +16 -0
- package/dist/wallets/phantom/index.d.ts +13 -0
- package/dist/wallets/types.d.ts +27 -0
- package/package.json +17 -40
- package/src/iframe/profile.ts +9 -7
- package/src/node/index.ts +1 -1
- package/tsup.node.config.ts +15 -0
- package/vite.config.js +83 -0
- package/dist/controller.cjs +0 -1272
- package/dist/controller.cjs.map +0 -1
- package/dist/controller.d.cts +0 -34
- package/dist/controller.js +0 -1270
- package/dist/controller.js.map +0 -1
- package/dist/index.cjs +0 -3389
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -68
- package/dist/lookup.cjs +0 -59
- package/dist/lookup.cjs.map +0 -1
- package/dist/lookup.d.cts +0 -4
- package/dist/lookup.js +0 -56
- package/dist/lookup.js.map +0 -1
- package/dist/policies-DD1aPjQ4.d.cts +0 -21
- package/dist/policies-DD1aPjQ4.d.ts +0 -21
- package/dist/provider-BeCgS86X.d.cts +0 -266
- package/dist/provider-BeCgS86X.d.ts +0 -266
- package/dist/session/index.cjs +0 -484
- package/dist/session/index.cjs.map +0 -1
- package/dist/session/index.js +0 -478
- package/dist/session/index.js.map +0 -1
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { constants, BigNumberish, Call, Abi, InvocationsDetails, WalletAccount } from 'starknet';
|
|
2
|
-
import { ChainId, AddInvokeTransactionResult, TypedData, Signature, StarknetWindowObject, WalletEvents, RequestFn, WalletEventListener, AddStarknetChainParameters } from '@starknet-io/types-js';
|
|
3
|
-
import { SessionPolicies, Policy } from '@cartridge/presets';
|
|
4
|
-
import { AsyncMethodReturns } from '@cartridge/penpal';
|
|
5
|
-
|
|
6
|
-
type IFrameOptions$1<CallSender> = Omit<ConstructorParameters<typeof IFrame>[0], "id" | "url" | "onConnect"> & {
|
|
7
|
-
url?: string;
|
|
8
|
-
onConnect: (child: AsyncMethodReturns<CallSender>) => void;
|
|
9
|
-
};
|
|
10
|
-
declare class IFrame<CallSender extends {}> implements Modal {
|
|
11
|
-
url?: URL;
|
|
12
|
-
private iframe?;
|
|
13
|
-
private container?;
|
|
14
|
-
private onClose?;
|
|
15
|
-
constructor({ id, url, preset, onClose, onConnect, methods, }: Pick<ControllerOptions, "preset"> & {
|
|
16
|
-
id: string;
|
|
17
|
-
url: URL;
|
|
18
|
-
onClose?: () => void;
|
|
19
|
-
onConnect: (child: AsyncMethodReturns<CallSender>) => void;
|
|
20
|
-
methods?: {
|
|
21
|
-
[key: string]: (...args: any[]) => void;
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
open(): void;
|
|
25
|
-
close(): void;
|
|
26
|
-
sendBackward(): void;
|
|
27
|
-
sendForward(): void;
|
|
28
|
-
private resize;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type ExternalWalletType = "argent" | "metamask" | "phantom";
|
|
32
|
-
type ExternalPlatform = "starknet" | "ethereum" | "solana";
|
|
33
|
-
interface ExternalWallet {
|
|
34
|
-
type: ExternalWalletType;
|
|
35
|
-
available: boolean;
|
|
36
|
-
version?: string;
|
|
37
|
-
chainId?: string;
|
|
38
|
-
name?: string;
|
|
39
|
-
platform?: ExternalPlatform;
|
|
40
|
-
}
|
|
41
|
-
interface ExternalWalletResponse<T = unknown> {
|
|
42
|
-
success: boolean;
|
|
43
|
-
wallet: ExternalWalletType;
|
|
44
|
-
result?: T;
|
|
45
|
-
error?: string;
|
|
46
|
-
account?: string;
|
|
47
|
-
}
|
|
48
|
-
interface WalletAdapter {
|
|
49
|
-
type: ExternalWalletType;
|
|
50
|
-
platform: ExternalPlatform;
|
|
51
|
-
isAvailable(): boolean;
|
|
52
|
-
getInfo(): ExternalWallet;
|
|
53
|
-
connect(): Promise<ExternalWalletResponse<any>>;
|
|
54
|
-
signMessage?(message: string): Promise<ExternalWalletResponse<any>>;
|
|
55
|
-
signTypedData?(data: any): Promise<ExternalWalletResponse<any>>;
|
|
56
|
-
getBalance(tokenAddress?: string): Promise<ExternalWalletResponse<any>>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
declare class WalletBridge {
|
|
60
|
-
private readonly walletAdapters;
|
|
61
|
-
private readonly connectedWallets;
|
|
62
|
-
constructor();
|
|
63
|
-
getIFrameMethods(): {
|
|
64
|
-
externalDetectWallets: (_origin: string) => () => Promise<ExternalWallet[]>;
|
|
65
|
-
externalConnectWallet: (_origin: string) => (type: ExternalWalletType) => Promise<ExternalWalletResponse<unknown>>;
|
|
66
|
-
externalSignMessage: (_origin: string) => (type: ExternalWalletType, message: string) => Promise<ExternalWalletResponse<unknown>>;
|
|
67
|
-
externalSignTypedData: (_origin: string) => (type: ExternalWalletType, data: any) => Promise<ExternalWalletResponse<unknown>>;
|
|
68
|
-
externalGetBalance: (_origin: string) => (type: ExternalWalletType, tokenAddress?: string) => Promise<ExternalWalletResponse<unknown>>;
|
|
69
|
-
};
|
|
70
|
-
detectWallets(): Promise<ExternalWallet[]>;
|
|
71
|
-
private getWalletAdapter;
|
|
72
|
-
private handleError;
|
|
73
|
-
connectWallet(type: ExternalWalletType): Promise<ExternalWalletResponse>;
|
|
74
|
-
signMessage(type: ExternalWalletType, message: string): Promise<ExternalWalletResponse>;
|
|
75
|
-
signTypedData(type: ExternalWalletType, data: any): Promise<ExternalWalletResponse>;
|
|
76
|
-
getBalance(type: ExternalWalletType, tokenAddress?: string): Promise<ExternalWalletResponse>;
|
|
77
|
-
}
|
|
78
|
-
declare global {
|
|
79
|
-
interface Window {
|
|
80
|
-
ethereum?: any;
|
|
81
|
-
solana?: any;
|
|
82
|
-
starknet_argentX?: any;
|
|
83
|
-
wallet_bridge?: WalletBridge;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
type KeychainIframeOptions = IFrameOptions$1<Keychain> & KeychainOptions;
|
|
88
|
-
declare class KeychainIFrame extends IFrame<Keychain> {
|
|
89
|
-
private walletBridge;
|
|
90
|
-
constructor({ url, policies, ...iframeOptions }: KeychainIframeOptions);
|
|
91
|
-
getWalletBridge(): WalletBridge;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type ProfileIFrameOptions = IFrameOptions$1<Profile> & ProfileOptions & {
|
|
95
|
-
rpcUrl: string;
|
|
96
|
-
version?: string;
|
|
97
|
-
username: string;
|
|
98
|
-
slot?: string;
|
|
99
|
-
namespace?: string;
|
|
100
|
-
};
|
|
101
|
-
declare class ProfileIFrame extends IFrame<Profile> {
|
|
102
|
-
constructor({ profileUrl, rpcUrl, version, username, slot, namespace, tokens, policies, ...iframeOptions }: ProfileIFrameOptions);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
type Session = {
|
|
106
|
-
chainId: constants.StarknetChainId;
|
|
107
|
-
policies: Policy[];
|
|
108
|
-
maxFee: BigNumberish;
|
|
109
|
-
expiresAt: bigint;
|
|
110
|
-
credentials: {
|
|
111
|
-
authorization: string[];
|
|
112
|
-
privateKey: string;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
declare enum ResponseCodes {
|
|
116
|
-
SUCCESS = "SUCCESS",
|
|
117
|
-
NOT_CONNECTED = "NOT_CONNECTED",
|
|
118
|
-
ERROR = "ERROR",
|
|
119
|
-
CANCELED = "CANCELED",
|
|
120
|
-
USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED"
|
|
121
|
-
}
|
|
122
|
-
type ConnectError = {
|
|
123
|
-
code: ResponseCodes;
|
|
124
|
-
message: string;
|
|
125
|
-
error?: ControllerError;
|
|
126
|
-
};
|
|
127
|
-
type ControllerError = {
|
|
128
|
-
code: Number;
|
|
129
|
-
message: string;
|
|
130
|
-
data?: any;
|
|
131
|
-
};
|
|
132
|
-
type ConnectReply = {
|
|
133
|
-
code: ResponseCodes.SUCCESS;
|
|
134
|
-
address: string;
|
|
135
|
-
policies?: SessionPolicies;
|
|
136
|
-
};
|
|
137
|
-
type ExecuteReply = (AddInvokeTransactionResult & {
|
|
138
|
-
code: ResponseCodes.SUCCESS;
|
|
139
|
-
}) | {
|
|
140
|
-
code: ResponseCodes.USER_INTERACTION_REQUIRED;
|
|
141
|
-
};
|
|
142
|
-
type ProbeReply = {
|
|
143
|
-
code: ResponseCodes.SUCCESS;
|
|
144
|
-
address: string;
|
|
145
|
-
rpcUrl?: string;
|
|
146
|
-
};
|
|
147
|
-
type DeployReply = {
|
|
148
|
-
code: ResponseCodes.SUCCESS;
|
|
149
|
-
transaction_hash: string;
|
|
150
|
-
};
|
|
151
|
-
type IFrames = {
|
|
152
|
-
keychain: KeychainIFrame;
|
|
153
|
-
profile?: ProfileIFrame;
|
|
154
|
-
version?: number;
|
|
155
|
-
};
|
|
156
|
-
interface LookupRequest {
|
|
157
|
-
usernames?: string[];
|
|
158
|
-
addresses?: string[];
|
|
159
|
-
}
|
|
160
|
-
interface LookupResult {
|
|
161
|
-
username: string;
|
|
162
|
-
addresses: string[];
|
|
163
|
-
}
|
|
164
|
-
interface LookupResponse {
|
|
165
|
-
results: LookupResult[];
|
|
166
|
-
}
|
|
167
|
-
type ContractAddress = string;
|
|
168
|
-
type CartridgeID = string;
|
|
169
|
-
type ControllerAccounts = Record<ContractAddress, CartridgeID>;
|
|
170
|
-
interface Keychain {
|
|
171
|
-
probe(rpcUrl: string): Promise<ProbeReply | ConnectError>;
|
|
172
|
-
connect(policies: SessionPolicies, rpcUrl: string): Promise<ConnectReply | ConnectError>;
|
|
173
|
-
disconnect(): void;
|
|
174
|
-
reset(): void;
|
|
175
|
-
revoke(origin: string): void;
|
|
176
|
-
deploy(): Promise<DeployReply | ConnectError>;
|
|
177
|
-
execute(calls: Call | Call[], abis?: Abi[], transactionsDetail?: InvocationsDetails, sync?: boolean, paymaster?: any, error?: ControllerError): Promise<ExecuteReply | ConnectError>;
|
|
178
|
-
signMessage(typedData: TypedData, account: string, async?: boolean): Promise<Signature | ConnectError>;
|
|
179
|
-
openSettings(): Promise<void | ConnectError>;
|
|
180
|
-
session(): Promise<Session>;
|
|
181
|
-
sessions(): Promise<{
|
|
182
|
-
[key: string]: Session;
|
|
183
|
-
}>;
|
|
184
|
-
delegateAccount(): string;
|
|
185
|
-
username(): string;
|
|
186
|
-
openPurchaseCredits(): void;
|
|
187
|
-
openExecute(calls: Call[]): Promise<void>;
|
|
188
|
-
switchChain(rpcUrl: string): Promise<void>;
|
|
189
|
-
externalDetectWallets(): Promise<ExternalWallet[]>;
|
|
190
|
-
externalConnectWallet(type: ExternalWalletType): Promise<ExternalWalletResponse>;
|
|
191
|
-
externalSignMessage(type: ExternalWalletType, message: string): Promise<ExternalWalletResponse>;
|
|
192
|
-
externalSignTypedData(type: ExternalWalletType, data: any): Promise<ExternalWalletResponse>;
|
|
193
|
-
externalGetBalance(type: ExternalWalletType, tokenAddress?: string): Promise<ExternalWalletResponse>;
|
|
194
|
-
}
|
|
195
|
-
interface Profile {
|
|
196
|
-
navigate(path: string): void;
|
|
197
|
-
switchChain(rpcUrl: string): Promise<void>;
|
|
198
|
-
}
|
|
199
|
-
interface Modal {
|
|
200
|
-
open: () => void;
|
|
201
|
-
close: () => void;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Options for configuring the controller
|
|
205
|
-
*/
|
|
206
|
-
type ControllerOptions = ProviderOptions & KeychainOptions & ProfileOptions;
|
|
207
|
-
type IFrameOptions = {
|
|
208
|
-
/** The ID of the starter pack to use */
|
|
209
|
-
starterPackId?: string;
|
|
210
|
-
/** The preset to use */
|
|
211
|
-
preset?: string;
|
|
212
|
-
};
|
|
213
|
-
type Chain = {
|
|
214
|
-
rpcUrl: string;
|
|
215
|
-
};
|
|
216
|
-
type ProviderOptions = {
|
|
217
|
-
defaultChainId: ChainId;
|
|
218
|
-
chains: Chain[];
|
|
219
|
-
};
|
|
220
|
-
type KeychainOptions = IFrameOptions & {
|
|
221
|
-
policies?: SessionPolicies;
|
|
222
|
-
/** The URL of keychain */
|
|
223
|
-
url?: string;
|
|
224
|
-
/** The origin of keychain */
|
|
225
|
-
origin?: string;
|
|
226
|
-
/** Propagate transaction errors back to caller instead of showing modal */
|
|
227
|
-
propagateSessionErrors?: boolean;
|
|
228
|
-
};
|
|
229
|
-
type ProfileOptions = IFrameOptions & {
|
|
230
|
-
/** The URL of profile. Mainly for internal development purpose */
|
|
231
|
-
profileUrl?: string;
|
|
232
|
-
/** The project name of Slot instance. */
|
|
233
|
-
slot?: string;
|
|
234
|
-
/** The namespace to use to fetch trophies data from indexer. Will be mandatory once profile page is in production */
|
|
235
|
-
namespace?: string;
|
|
236
|
-
/** The tokens to be listed on Inventory modal */
|
|
237
|
-
tokens?: Tokens;
|
|
238
|
-
/** The policies to use for the profile */
|
|
239
|
-
policies?: SessionPolicies;
|
|
240
|
-
};
|
|
241
|
-
type ProfileContextTypeVariant = "inventory" | "trophies" | "achievements" | "activity";
|
|
242
|
-
type Tokens = {
|
|
243
|
-
erc20?: string[];
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
declare abstract class BaseProvider implements StarknetWindowObject {
|
|
247
|
-
id: string;
|
|
248
|
-
name: string;
|
|
249
|
-
version: string;
|
|
250
|
-
icon: string;
|
|
251
|
-
account?: WalletAccount;
|
|
252
|
-
subscriptions: WalletEvents[];
|
|
253
|
-
private _probePromise;
|
|
254
|
-
protected safeProbe(): Promise<WalletAccount | undefined>;
|
|
255
|
-
request: RequestFn;
|
|
256
|
-
on: WalletEventListener;
|
|
257
|
-
off: WalletEventListener;
|
|
258
|
-
protected emitNetworkChanged(chainId: string): void;
|
|
259
|
-
protected emitAccountsChanged(accounts: string[]): void;
|
|
260
|
-
abstract probe(): Promise<WalletAccount | undefined>;
|
|
261
|
-
abstract connect(): Promise<WalletAccount | undefined>;
|
|
262
|
-
abstract switchStarknetChain(chainId: string): Promise<boolean>;
|
|
263
|
-
abstract addStarknetChain(chain: AddStarknetChainParameters): Promise<boolean>;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export { BaseProvider as B, type ConnectError as C, type DeployReply as D, type ExternalWalletType as E, type IFrames as I, type Keychain as K, type LookupRequest as L, type Modal as M, type ProbeReply as P, ResponseCodes as R, type Session as S, type Tokens as T, type WalletAdapter as W, type ExternalPlatform as a, type ExternalWallet as b, type ExternalWalletResponse as c, type ControllerError as d, type ConnectReply as e, type ExecuteReply as f, type LookupResult as g, type LookupResponse as h, type ControllerAccounts as i, type Profile as j, type ControllerOptions as k, type IFrameOptions as l, type Chain as m, type ProviderOptions as n, type KeychainOptions as o, type ProfileOptions as p, type ProfileContextTypeVariant as q, WalletBridge as r };
|