@cardano-sdk/dapp-connector 0.12.38 → 0.12.40
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/dist/cjs/WalletApi/Cip30Wallet.d.ts +5 -0
- package/dist/cjs/WalletApi/Cip30Wallet.d.ts.map +1 -1
- package/dist/cjs/WalletApi/Cip30Wallet.js +47 -38
- package/dist/cjs/WalletApi/Cip30Wallet.js.map +1 -1
- package/dist/cjs/injectGlobal.d.ts +1 -1
- package/dist/cjs/injectGlobal.d.ts.map +1 -1
- package/dist/cjs/injectGlobal.js +3 -2
- package/dist/cjs/injectGlobal.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/WalletApi/Cip30Wallet.d.ts +5 -0
- package/dist/esm/WalletApi/Cip30Wallet.d.ts.map +1 -1
- package/dist/esm/WalletApi/Cip30Wallet.js +47 -38
- package/dist/esm/WalletApi/Cip30Wallet.js.map +1 -1
- package/dist/esm/injectGlobal.d.ts +1 -1
- package/dist/esm/injectGlobal.d.ts.map +1 -1
- package/dist/esm/injectGlobal.js +3 -2
- package/dist/esm/injectGlobal.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -9,6 +9,11 @@ export declare type WalletIcon = string;
|
|
|
9
9
|
export declare type WalletProperties = {
|
|
10
10
|
icon: WalletIcon;
|
|
11
11
|
walletName: WalletName;
|
|
12
|
+
supportedExtensions?: WalletApiExtension[];
|
|
13
|
+
cip30ApiDeviations?: {
|
|
14
|
+
getCollateralEmptyArray?: boolean;
|
|
15
|
+
onOffDummyMethods?: boolean;
|
|
16
|
+
};
|
|
12
17
|
};
|
|
13
18
|
export declare type WalletDependencies = {
|
|
14
19
|
logger: Logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cip30Wallet.d.ts","sourceRoot":"","sources":["../../../src/WalletApi/Cip30Wallet.ts"],"names":[],"mappings":"AAC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,EAAE,SAAS,CAAC;CAChB,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAAC;AAGtE,qBAAa,WAAW;;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAW;IAC1C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B,QAAQ,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,CAAiB;gBAOvD,UAAU,EAAE,gBAAgB,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,kBAAkB;IAoC/E,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAmB7B,MAAM,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,oCAAoC,CAAC;CAiEjG"}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _Cip30Wallet_instances, _Cip30Wallet_logger, _Cip30Wallet_api, _Cip30Wallet_authenticator, _Cip30Wallet_validateExtensions;
|
|
12
|
+
var _Cip30Wallet_instances, _Cip30Wallet_logger, _Cip30Wallet_api, _Cip30Wallet_authenticator, _Cip30Wallet_deviations, _Cip30Wallet_validateExtensions, _Cip30Wallet_wrapGetCollateral, _Cip30Wallet_wrapAndEnableApi;
|
|
13
13
|
import { APIErrorCode, ApiError } from '../errors/index.js';
|
|
14
14
|
export const CipMethodsMapping = {
|
|
15
15
|
30: [
|
|
@@ -29,41 +29,6 @@ export const CipMethodsMapping = {
|
|
|
29
29
|
95: ['getRegisteredPubStakeKeys', 'getUnregisteredPubStakeKeys', 'getPubDRepKey']
|
|
30
30
|
};
|
|
31
31
|
export const WalletApiMethodNames = Object.values(CipMethodsMapping).flat();
|
|
32
|
-
const wrapAndEnableApi = (walletApi, enabledExtensions) => {
|
|
33
|
-
const baseApi = {
|
|
34
|
-
experimental: {
|
|
35
|
-
getCollateral: (params) => walletApi.getCollateral(params)
|
|
36
|
-
},
|
|
37
|
-
getBalance: () => walletApi.getBalance(),
|
|
38
|
-
getChangeAddress: () => walletApi.getChangeAddress(),
|
|
39
|
-
getCollateral: (params) => walletApi.getCollateral(params),
|
|
40
|
-
getExtensions: () => Promise.resolve(enabledExtensions || []),
|
|
41
|
-
getNetworkId: () => walletApi.getNetworkId(),
|
|
42
|
-
getRewardAddresses: () => walletApi.getRewardAddresses(),
|
|
43
|
-
getUnusedAddresses: () => walletApi.getUnusedAddresses(),
|
|
44
|
-
getUsedAddresses: (paginate) => walletApi.getUsedAddresses(paginate),
|
|
45
|
-
getUtxos: (amount, paginate) => walletApi.getUtxos(amount, paginate),
|
|
46
|
-
signData: (addr, payload) => walletApi.signData(addr, payload),
|
|
47
|
-
signTx: (tx, partialSign) => walletApi.signTx(tx, partialSign),
|
|
48
|
-
submitTx: (tx) => walletApi.submitTx(tx)
|
|
49
|
-
};
|
|
50
|
-
const additionalCipApis = {
|
|
51
|
-
cip95: {
|
|
52
|
-
getPubDRepKey: () => walletApi.getPubDRepKey(),
|
|
53
|
-
getRegisteredPubStakeKeys: () => walletApi.getRegisteredPubStakeKeys(),
|
|
54
|
-
getUnregisteredPubStakeKeys: () => walletApi.getUnregisteredPubStakeKeys()
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
if (enabledExtensions) {
|
|
58
|
-
for (const extension of enabledExtensions) {
|
|
59
|
-
const cipName = `cip${extension.cip}`;
|
|
60
|
-
if (additionalCipApis[cipName]) {
|
|
61
|
-
baseApi[cipName] = additionalCipApis[cipName];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return baseApi;
|
|
66
|
-
};
|
|
67
32
|
export class Cip30Wallet {
|
|
68
33
|
constructor(properties, { api, authenticator, logger }) {
|
|
69
34
|
_Cip30Wallet_instances.add(this);
|
|
@@ -72,13 +37,18 @@ export class Cip30Wallet {
|
|
|
72
37
|
_Cip30Wallet_logger.set(this, void 0);
|
|
73
38
|
_Cip30Wallet_api.set(this, void 0);
|
|
74
39
|
_Cip30Wallet_authenticator.set(this, void 0);
|
|
40
|
+
_Cip30Wallet_deviations.set(this, void 0);
|
|
75
41
|
this.icon = properties.icon;
|
|
76
42
|
this.name = properties.walletName;
|
|
77
43
|
__classPrivateFieldSet(this, _Cip30Wallet_api, api, "f");
|
|
78
44
|
__classPrivateFieldSet(this, _Cip30Wallet_logger, logger, "f");
|
|
79
45
|
__classPrivateFieldSet(this, _Cip30Wallet_authenticator, authenticator, "f");
|
|
46
|
+
__classPrivateFieldSet(this, _Cip30Wallet_deviations, properties.cip30ApiDeviations, "f");
|
|
80
47
|
this.enable = this.enable.bind(this);
|
|
81
48
|
this.isEnabled = this.isEnabled.bind(this);
|
|
49
|
+
if (properties.supportedExtensions) {
|
|
50
|
+
this.supportedExtensions = properties.supportedExtensions;
|
|
51
|
+
}
|
|
82
52
|
}
|
|
83
53
|
async isEnabled() {
|
|
84
54
|
return __classPrivateFieldGet(this, _Cip30Wallet_authenticator, "f").haveAccess();
|
|
@@ -88,17 +58,56 @@ export class Cip30Wallet {
|
|
|
88
58
|
if (await __classPrivateFieldGet(this, _Cip30Wallet_authenticator, "f").requestAccess()) {
|
|
89
59
|
__classPrivateFieldGet(this, _Cip30Wallet_logger, "f").debug(`${location.origin} has been granted access to wallet api`);
|
|
90
60
|
const extensions = options?.extensions?.filter(({ cip: requestedCip }) => this.supportedExtensions.some(({ cip: supportedCip }) => supportedCip === requestedCip));
|
|
91
|
-
return
|
|
61
|
+
return __classPrivateFieldGet(this, _Cip30Wallet_instances, "m", _Cip30Wallet_wrapAndEnableApi).call(this, extensions);
|
|
92
62
|
}
|
|
93
63
|
__classPrivateFieldGet(this, _Cip30Wallet_logger, "f").debug(`${location.origin} not authorized to access wallet api`);
|
|
94
64
|
throw new ApiError(APIErrorCode.Refused, 'wallet not authorized.');
|
|
95
65
|
}
|
|
96
66
|
}
|
|
97
|
-
_Cip30Wallet_logger = new WeakMap(), _Cip30Wallet_api = new WeakMap(), _Cip30Wallet_authenticator = new WeakMap(), _Cip30Wallet_instances = new WeakSet(), _Cip30Wallet_validateExtensions = function _Cip30Wallet_validateExtensions(extensions = []) {
|
|
67
|
+
_Cip30Wallet_logger = new WeakMap(), _Cip30Wallet_api = new WeakMap(), _Cip30Wallet_authenticator = new WeakMap(), _Cip30Wallet_deviations = new WeakMap(), _Cip30Wallet_instances = new WeakSet(), _Cip30Wallet_validateExtensions = function _Cip30Wallet_validateExtensions(extensions = []) {
|
|
98
68
|
if (!Array.isArray(extensions) ||
|
|
99
69
|
extensions.some((extension) => !extension || typeof extension !== 'object' || !extension.cip || Number.isNaN(Number(extension.cip)))) {
|
|
100
70
|
__classPrivateFieldGet(this, _Cip30Wallet_logger, "f").debug(`Invalid extensions: ${extensions}`);
|
|
101
71
|
throw new ApiError(APIErrorCode.InvalidRequest, `invalid extensions ${extensions}`);
|
|
102
72
|
}
|
|
73
|
+
}, _Cip30Wallet_wrapGetCollateral = async function _Cip30Wallet_wrapGetCollateral(params) {
|
|
74
|
+
const collateral = await __classPrivateFieldGet(this, _Cip30Wallet_api, "f").getCollateral(params);
|
|
75
|
+
return __classPrivateFieldGet(this, _Cip30Wallet_deviations, "f")?.getCollateralEmptyArray ? collateral ?? [] : collateral;
|
|
76
|
+
}, _Cip30Wallet_wrapAndEnableApi = function _Cip30Wallet_wrapAndEnableApi(enabledExtensions) {
|
|
77
|
+
const walletApi = __classPrivateFieldGet(this, _Cip30Wallet_api, "f");
|
|
78
|
+
const baseApi = {
|
|
79
|
+
experimental: {
|
|
80
|
+
getCollateral: async (params) => __classPrivateFieldGet(this, _Cip30Wallet_instances, "m", _Cip30Wallet_wrapGetCollateral).call(this, params),
|
|
81
|
+
...(__classPrivateFieldGet(this, _Cip30Wallet_deviations, "f")?.onOffDummyMethods && { off: () => void 0, on: () => void 0 })
|
|
82
|
+
},
|
|
83
|
+
getBalance: () => walletApi.getBalance(),
|
|
84
|
+
getChangeAddress: () => walletApi.getChangeAddress(),
|
|
85
|
+
getCollateral: (params) => __classPrivateFieldGet(this, _Cip30Wallet_instances, "m", _Cip30Wallet_wrapGetCollateral).call(this, params),
|
|
86
|
+
getExtensions: () => Promise.resolve(enabledExtensions || []),
|
|
87
|
+
getNetworkId: () => walletApi.getNetworkId(),
|
|
88
|
+
getRewardAddresses: () => walletApi.getRewardAddresses(),
|
|
89
|
+
getUnusedAddresses: () => walletApi.getUnusedAddresses(),
|
|
90
|
+
getUsedAddresses: (paginate) => walletApi.getUsedAddresses(paginate),
|
|
91
|
+
getUtxos: (amount, paginate) => walletApi.getUtxos(amount, paginate),
|
|
92
|
+
signData: (addr, payload) => walletApi.signData(addr, payload),
|
|
93
|
+
signTx: (tx, partialSign) => walletApi.signTx(tx, partialSign),
|
|
94
|
+
submitTx: (tx) => walletApi.submitTx(tx)
|
|
95
|
+
};
|
|
96
|
+
const additionalCipApis = {
|
|
97
|
+
cip95: {
|
|
98
|
+
getPubDRepKey: () => walletApi.getPubDRepKey(),
|
|
99
|
+
getRegisteredPubStakeKeys: () => walletApi.getRegisteredPubStakeKeys(),
|
|
100
|
+
getUnregisteredPubStakeKeys: () => walletApi.getUnregisteredPubStakeKeys()
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
if (enabledExtensions) {
|
|
104
|
+
for (const extension of enabledExtensions) {
|
|
105
|
+
const cipName = `cip${extension.cip}`;
|
|
106
|
+
if (additionalCipApis[cipName]) {
|
|
107
|
+
baseApi[cipName] = additionalCipApis[cipName];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return baseApi;
|
|
103
112
|
};
|
|
104
113
|
//# sourceMappingURL=Cip30Wallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cip30Wallet.js","sourceRoot":"","sources":["../../../src/WalletApi/Cip30Wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAenD,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAC/D,EAAE,EAAE;QACF,cAAc;QACd,UAAU;QACV,eAAe;QACf,YAAY;QACZ,eAAe;QACf,kBAAkB;QAClB,oBAAoB;QACpB,kBAAkB;QAClB,oBAAoB;QACpB,QAAQ;QACR,UAAU;QACV,UAAU;KACX;IACD,EAAE,EAAE,CAAC,2BAA2B,EAAE,6BAA6B,EAAE,eAAe,CAAC;CAClF,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAmB,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Cip30Wallet.js","sourceRoot":"","sources":["../../../src/WalletApi/Cip30Wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAenD,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAC/D,EAAE,EAAE;QACF,cAAc;QACd,UAAU;QACV,eAAe;QACf,YAAY;QACZ,eAAe;QACf,kBAAkB;QAClB,oBAAoB;QACpB,kBAAkB;QAClB,oBAAoB;QACpB,QAAQ;QACR,UAAU;QACV,UAAU;KACX;IACD,EAAE,EAAE,CAAC,2BAA2B,EAAE,6BAA6B,EAAE,eAAe,CAAC;CAClF,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAmB,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,EAAE,CAAC;AA4C5F,MAAM,OAAO,WAAW;IAYtB,YAAY,UAA4B,EAAE,EAAE,GAAG,EAAE,aAAa,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AC;QAC9E,QAAQ,EAAE,CAAC,EAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;KAC/C,CAAC;IAEF,MAAM,iBAAiB,GAAqB;QAC1C,KAAK,EAAE;YACL,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE;YAC9C,yBAAyB,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,yBAAyB,EAAE;YACtE,2BAA2B,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,2BAA2B,EAAE;SAC3E;KACF,CAAC;IAEF,IAAI,iBAAiB,EAAE;QACrB,KAAK,MAAM,SAAS,IAAI,iBAAiB,EAAE;YACzC,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,GAAG,EAA4B,CAAC;YAChE,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE;gBAC9B,OAAO,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;aAC/C;SACF;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -5,5 +5,5 @@ export declare type WindowMaybeWithCardano = Window & {
|
|
|
5
5
|
[k: string]: Cip30Wallet;
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
|
-
export declare const injectGlobal: (window: WindowMaybeWithCardano, wallet: Cip30Wallet, logger: Logger) => void;
|
|
8
|
+
export declare const injectGlobal: (window: WindowMaybeWithCardano, wallet: Cip30Wallet, logger: Logger, injectKey?: string) => void;
|
|
9
9
|
//# sourceMappingURL=injectGlobal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectGlobal.d.ts","sourceRoot":"","sources":["../../src/injectGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,oBAAY,sBAAsB,GAAG,MAAM,GAAG;IAAE,OAAO,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAA;CAAE,CAAC;AAEzF,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"injectGlobal.d.ts","sourceRoot":"","sources":["../../src/injectGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,oBAAY,sBAAsB,GAAG,MAAM,GAAG;IAAE,OAAO,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAA;CAAE,CAAC;AAEzF,eAAO,MAAM,YAAY,WACf,sBAAsB,UACtB,WAAW,UACX,MAAM,cACF,MAAM,KACjB,IA6BF,CAAC"}
|
package/dist/esm/injectGlobal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export const injectGlobal = (window, wallet, logger) => {
|
|
1
|
+
export const injectGlobal = (window, wallet, logger, injectKey) => {
|
|
2
|
+
injectKey = injectKey ?? wallet.name;
|
|
2
3
|
if (!window.cardano) {
|
|
3
4
|
logger.debug({
|
|
4
5
|
module: 'injectWindow',
|
|
@@ -12,7 +13,7 @@ export const injectGlobal = (window, wallet, logger) => {
|
|
|
12
13
|
wallet: { apiVersion: wallet.apiVersion, icon: wallet.icon, name: wallet.name }
|
|
13
14
|
}, 'Cardano global scope exists');
|
|
14
15
|
}
|
|
15
|
-
window.cardano[
|
|
16
|
+
window.cardano[injectKey] = window.cardano[injectKey] || wallet;
|
|
16
17
|
logger.debug({
|
|
17
18
|
module: 'injectWindow',
|
|
18
19
|
wallet: { apiVersion: wallet.apiVersion, icon: wallet.icon, name: wallet.name },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectGlobal.js","sourceRoot":"","sources":["../../src/injectGlobal.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"injectGlobal.js","sourceRoot":"","sources":["../../src/injectGlobal.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAA8B,EAC9B,MAAmB,EACnB,MAAc,EACd,SAAkB,EACZ,EAAE;IACR,SAAS,GAAG,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,KAAK,CACV;YACE,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;SAChF,EACD,+BAA+B,CAChC,CAAC;QACF,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;KACrB;SAAM;QACL,MAAM,CAAC,KAAK,CACV;YACE,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;SAChF,EACD,6BAA6B,CAC9B,CAAC;KACH;IACD,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC;IAChE,MAAM,CAAC,KAAK,CACV;QACE,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;QAC/E,aAAa,EAAE,MAAM,CAAC,OAAO;KAC9B,EACD,UAAU,CACX,CAAC;AACJ,CAAC,CAAC"}
|