@cartridge/controller 0.1.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.
@@ -0,0 +1,89 @@
1
+ import { AccountInterface, DeployContractPayload, Abi, Call, DeployContractResponse as StarknetDeployContractResponse, InvocationsDetails, Signature, typedData, number, Provider, Invocation, SignerInterface, InvokeFunctionResponse } from "starknet";
2
+ import { EstimateFee } from "starknet/types/account";
3
+ import { Messenger } from "./messenger";
4
+ import { Scope } from "./types";
5
+ export declare class Account extends Provider implements AccountInterface {
6
+ address: string;
7
+ private messenger;
8
+ private url;
9
+ private _scopes;
10
+ signer: SignerInterface;
11
+ constructor(address: string, scopes: Scope[], messenger: Messenger, options?: {
12
+ url?: string;
13
+ });
14
+ /**
15
+ * Deploys a given compiled contract (json) to starknet
16
+ *
17
+ * @param payload payload to be deployed containing:
18
+ * - compiled contract code
19
+ * - constructor calldata
20
+ * - address salt
21
+ * @param abi the abi of the contract
22
+ * @returns a confirmation of sending a transaction on the starknet contract
23
+ */
24
+ deployContract(payload: DeployContractPayload, abi?: Abi): Promise<StarknetDeployContractResponse>;
25
+ /**
26
+ * Estimate Fee for a method on starknet
27
+ *
28
+ * @param invocation the invocation object containing:
29
+ * - contractAddress - the address of the contract
30
+ * - entrypoint - the entrypoint of the contract
31
+ * - calldata - (defaults to []) the calldata
32
+ * - signature - (defaults to []) the signature
33
+ *
34
+ * @returns response from addTransaction
35
+ */
36
+ estimateFee(invocation: Invocation): Promise<EstimateFee>;
37
+ /**
38
+ * Invoke execute function in account contract
39
+ *
40
+ * @param transactions the invocation object or an array of them, containing:
41
+ * - contractAddress - the address of the contract
42
+ * - entrypoint - the entrypoint of the contract
43
+ * - calldata - (defaults to []) the calldata
44
+ * - signature - (defaults to []) the signature
45
+ * @param abi (optional) the abi of the contract for better displaying
46
+ *
47
+ * @returns response from addTransaction
48
+ */
49
+ execute(transactions: Call | Call[], abis?: Abi[], transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
50
+ /**
51
+ * Sign an JSON object for off-chain usage with the starknet private key and return the signature
52
+ * This adds a message prefix so it cant be interchanged with transactions
53
+ *
54
+ * @param json - JSON object to be signed
55
+ * @returns the signature of the JSON object
56
+ * @throws {Error} if the JSON object is not a valid JSON
57
+ */
58
+ signMessage(typedData: typedData.TypedData): Promise<Signature>;
59
+ /**
60
+ * Hash a JSON object with pederson hash and return the hash
61
+ * This adds a message prefix so it cant be interchanged with transactions
62
+ *
63
+ * @param json - JSON object to be hashed
64
+ * @returns the hash of the JSON object
65
+ * @throws {Error} if the JSON object is not a valid JSON
66
+ */
67
+ hashMessage(typedData: typedData.TypedData): Promise<string>;
68
+ /**
69
+ * Verify a signature of a JSON object
70
+ *
71
+ * @param json - JSON object to be verified
72
+ * @param signature - signature of the JSON object
73
+ * @returns true if the signature is valid, false otherwise
74
+ * @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
75
+ */
76
+ verifyMessage(typedData: typedData.TypedData, signature: Signature): Promise<boolean>;
77
+ /**
78
+ * Verify a signature of a given hash
79
+ * @warning This method is not recommended, use verifyMessage instead
80
+ *
81
+ * @param hash - hash to be verified
82
+ * @param signature - signature of the hash
83
+ * @returns true if the signature is valid, false otherwise
84
+ * @throws {Error} if the signature is not a valid signature
85
+ */
86
+ verifyMessageHash(hash: number.BigNumberish, signature: Signature): Promise<boolean>;
87
+ getNonce(): Promise<string>;
88
+ }
89
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,GAAG,EACH,IAAI,EACJ,sBAAsB,IAAI,8BAA8B,EACxD,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,UAAU,EACV,eAAe,EACf,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,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E,MAAM,CAAC,YAAY,EACzB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC;IAgBb,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAWlC"}
@@ -0,0 +1,23 @@
1
+ import { Message, Messenger } from "./messenger";
2
+ import { Scope } from "./types";
3
+ import { AccountInterface } from "starknet";
4
+ export declare class Cartridge {
5
+ private selector;
6
+ private messenger?;
7
+ private scopes;
8
+ private url;
9
+ private origin;
10
+ private loading;
11
+ private ready_;
12
+ private account;
13
+ constructor(scopes?: Scope[], options?: {
14
+ url?: string;
15
+ origin?: string;
16
+ });
17
+ ready(): Promise<boolean>;
18
+ probe(): Promise<AccountInterface>;
19
+ connect(): Promise<AccountInterface>;
20
+ }
21
+ export { Message, Messenger };
22
+ export * from "./types";
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAkD,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,GAAG,CAAkC;IAC7C,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,OAAO,CAAmB;gBAGhC,MAAM,CAAC,EAAE,KAAK,EAAE,EAChB,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAuDG,KAAK;IAKL,KAAK;IAmBL,OAAO;CA2Cd;AAED,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC9B,cAAc,SAAS,CAAC"}