@cartridge/controller 0.5.0-alpha.1 → 0.5.0-alpha.3
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 +2 -2
- package/dist/controller.d.ts +1 -0
- package/dist/controller.js +22 -0
- package/dist/controller.js.map +1 -1
- package/dist/iframe/base.js +1 -0
- package/dist/iframe/base.js.map +1 -1
- package/dist/iframe/profile.d.ts +2 -1
- package/dist/iframe/profile.js +2 -1
- package/dist/iframe/profile.js.map +1 -1
- package/dist/presets.js +9 -0
- package/dist/presets.js.map +1 -1
- package/dist/provider.js +2 -5
- package/dist/provider.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +3 -3
- package/src/controller.ts +23 -0
- package/src/iframe/base.ts +3 -0
- package/src/iframe/profile.ts +3 -0
- package/src/presets.ts +9 -0
- package/src/provider.ts +2 -6
- package/src/types.ts +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-format.log +0 -25
- package/dist/device.d.ts +0 -46
- package/dist/device.js +0 -95
- package/dist/device.js.map +0 -1
- package/dist/session.d.ts +0 -40
- package/dist/session.js +0 -44
- package/dist/session.js.map +0 -1
- package/dist/signer.d.ts +0 -53
- package/dist/signer.js +0 -83
- package/dist/signer.js.map +0 -1
package/dist/device.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Account, RpcProvider, } from "starknet";
|
|
2
|
-
import { ResponseCodes, } from "./types";
|
|
3
|
-
import { Signer } from "./signer";
|
|
4
|
-
class DeviceAccount extends Account {
|
|
5
|
-
constructor(rpcUrl, address, keychain, options, modal) {
|
|
6
|
-
super(new RpcProvider({ nodeUrl: rpcUrl }), address, new Signer(keychain, modal));
|
|
7
|
-
this.address = address;
|
|
8
|
-
this.keychain = keychain;
|
|
9
|
-
this.options = options;
|
|
10
|
-
this.modal = modal;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Estimate Fee for a method on starknet
|
|
14
|
-
*
|
|
15
|
-
* @param calls the invocation object containing:
|
|
16
|
-
* - contractAddress - the address of the contract
|
|
17
|
-
* - entrypoint - the entrypoint of the contract
|
|
18
|
-
* - calldata - (defaults to []) the calldata
|
|
19
|
-
* - signature - (defaults to []) the signature
|
|
20
|
-
*
|
|
21
|
-
* @returns response from addTransaction
|
|
22
|
-
*/
|
|
23
|
-
async estimateInvokeFee(calls, details) {
|
|
24
|
-
return this.keychain.estimateInvokeFee(calls, {
|
|
25
|
-
...details,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
async estimateDeclareFee(payload, details) {
|
|
29
|
-
return this.keychain.estimateDeclareFee(payload, {
|
|
30
|
-
...details,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Invoke execute function in account contract
|
|
35
|
-
*
|
|
36
|
-
* @param calls the invocation object or an array of them, containing:
|
|
37
|
-
* - contractAddress - the address of the contract
|
|
38
|
-
* - entrypoint - the entrypoint of the contract
|
|
39
|
-
* - calldata - (defaults to []) the calldata
|
|
40
|
-
* - signature - (defaults to []) the signature
|
|
41
|
-
* @param abis (optional) the abi of the contract for better displaying
|
|
42
|
-
*
|
|
43
|
-
* @returns response from addTransaction
|
|
44
|
-
*/
|
|
45
|
-
// @ts-expect-error TODO: fix overload type mismatch
|
|
46
|
-
async execute(calls, abis, transactionsDetail = {}) {
|
|
47
|
-
return new Promise(async (resolve, reject) => {
|
|
48
|
-
const sessionExecute = await this.keychain.execute(calls, abis, transactionsDetail, false, this.options?.paymaster);
|
|
49
|
-
// Session call succeeded
|
|
50
|
-
if (sessionExecute.code === ResponseCodes.SUCCESS) {
|
|
51
|
-
resolve(sessionExecute);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// Propagates session txn error back to caller
|
|
55
|
-
if (this.options?.propagateSessionErrors) {
|
|
56
|
-
reject(sessionExecute.error);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// Session call or Paymaster flow failed.
|
|
60
|
-
// Session not avaialble, manual flow fallback
|
|
61
|
-
this.modal.open();
|
|
62
|
-
const manualExecute = await this.keychain.execute(calls, abis, transactionsDetail, true, this.options?.paymaster, sessionExecute.error);
|
|
63
|
-
// Manual call succeeded
|
|
64
|
-
if (manualExecute.code === ResponseCodes.SUCCESS) {
|
|
65
|
-
resolve(manualExecute);
|
|
66
|
-
this.modal.close();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
reject(manualExecute.error);
|
|
70
|
-
return;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
75
|
-
* This adds a message prefix so it cant be interchanged with transactions
|
|
76
|
-
*
|
|
77
|
-
* @param json - JSON object to be signed
|
|
78
|
-
* @returns the signature of the JSON object
|
|
79
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
80
|
-
*/
|
|
81
|
-
async signMessage(typedData) {
|
|
82
|
-
try {
|
|
83
|
-
this.modal.open();
|
|
84
|
-
const res = await this.keychain.signMessage(typedData, this.address);
|
|
85
|
-
this.modal.close();
|
|
86
|
-
return res;
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
console.error(e);
|
|
90
|
-
throw e;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
export default DeviceAccount;
|
|
95
|
-
//# sourceMappingURL=device.js.map
|
package/dist/device.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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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
-
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
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
package/dist/session.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Abi, BigNumberish, Call, DeclareSignerDetails, DeployAccountSignerDetails, InvocationsSignerDetails, Signature, SignerInterface, TypedData } from "starknet";
|
|
2
|
-
import { Keychain, Modal } from "./types";
|
|
3
|
-
import { AsyncMethodReturns } from "@cartridge/penpal";
|
|
4
|
-
import { CartridgeSessionAccount } from "@cartridge/account-wasm/session";
|
|
5
|
-
export declare class Signer implements SignerInterface {
|
|
6
|
-
private keychain;
|
|
7
|
-
modal: Modal;
|
|
8
|
-
constructor(keychain: AsyncMethodReturns<Keychain>, modal: Modal);
|
|
9
|
-
/**
|
|
10
|
-
* Method to get the public key of the signer
|
|
11
|
-
*
|
|
12
|
-
* @returns public key of signer as hex string with 0x prefix
|
|
13
|
-
*/
|
|
14
|
-
getPubKey(): Promise<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
17
|
-
* This adds a message prefix so it cant be interchanged with transactions
|
|
18
|
-
*
|
|
19
|
-
* @param typedData - JSON object to be signed
|
|
20
|
-
* @param accountAddress - account
|
|
21
|
-
* @returns the signature of the JSON object
|
|
22
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
23
|
-
*/
|
|
24
|
-
signMessage(typedData: TypedData, account: string): Promise<Signature>;
|
|
25
|
-
signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
|
|
26
|
-
signDeployAccountTransaction(transaction: DeployAccountSignerDetails): Promise<Signature>;
|
|
27
|
-
signDeclareTransaction(transaction: DeclareSignerDetails): Promise<Signature>;
|
|
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
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { normalizeCalls } from "./utils";
|
|
2
|
-
export class Signer {
|
|
3
|
-
constructor(keychain, modal) {
|
|
4
|
-
this.keychain = keychain;
|
|
5
|
-
this.modal = modal;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Method to get the public key of the signer
|
|
9
|
-
*
|
|
10
|
-
* @returns public key of signer as hex string with 0x prefix
|
|
11
|
-
*/
|
|
12
|
-
getPubKey() {
|
|
13
|
-
return Promise.resolve("");
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
17
|
-
* This adds a message prefix so it cant be interchanged with transactions
|
|
18
|
-
*
|
|
19
|
-
* @param typedData - JSON object to be signed
|
|
20
|
-
* @param accountAddress - account
|
|
21
|
-
* @returns the signature of the JSON object
|
|
22
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
23
|
-
*/
|
|
24
|
-
async signMessage(typedData, account) {
|
|
25
|
-
this.modal.open();
|
|
26
|
-
const res = await this.keychain.signMessage(typedData, account);
|
|
27
|
-
this.modal.close();
|
|
28
|
-
return res;
|
|
29
|
-
}
|
|
30
|
-
async signTransaction(transactions, transactionsDetail, abis) {
|
|
31
|
-
this.modal.open();
|
|
32
|
-
const res = await this.keychain.signTransaction(transactions, transactionsDetail, abis);
|
|
33
|
-
this.modal.close();
|
|
34
|
-
return res;
|
|
35
|
-
}
|
|
36
|
-
async signDeployAccountTransaction(transaction) {
|
|
37
|
-
this.modal.open();
|
|
38
|
-
const res = await this.keychain.signDeployAccountTransaction(transaction);
|
|
39
|
-
this.modal.close();
|
|
40
|
-
return res;
|
|
41
|
-
}
|
|
42
|
-
async signDeclareTransaction(transaction) {
|
|
43
|
-
this.modal.open();
|
|
44
|
-
const res = await this.keychain.signDeclareTransaction(transaction);
|
|
45
|
-
this.modal.close();
|
|
46
|
-
return res;
|
|
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
|
-
}
|
|
83
|
-
//# sourceMappingURL=signer.js.map
|
package/dist/signer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,CACtB,SAAoB,EACpB,OAAe;QAEf,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,GAAgB,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,eAAe,CAC1B,YAAoB,EACpB,kBAA4C,EAC5C,IAAY;QAEZ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;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