@massalabs/wallet-provider 0.0.1-dev.20230525084049 → 0.0.1-dev.20230525092413
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/bundle.js
CHANGED
|
@@ -769,7 +769,7 @@ class ThyraAccount {
|
|
|
769
769
|
async sign(data) {
|
|
770
770
|
let signOpResponse = null;
|
|
771
771
|
try {
|
|
772
|
-
signOpResponse = await (0, RequestHandler_1.postRequest)(`${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/
|
|
772
|
+
signOpResponse = await (0, RequestHandler_1.postRequest)(`${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/sign`, {
|
|
773
773
|
operation: data,
|
|
774
774
|
batch: false,
|
|
775
775
|
});
|
|
@@ -790,8 +790,25 @@ class ThyraAccount {
|
|
|
790
790
|
* @param fee - The fee to be paid for the transaction execution by the node.
|
|
791
791
|
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
792
792
|
*/
|
|
793
|
-
buyRolls(amount, fee) {
|
|
794
|
-
|
|
793
|
+
async buyRolls(amount, fee) {
|
|
794
|
+
let buyRollsOpResponse = null;
|
|
795
|
+
const url = `${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/rolls`;
|
|
796
|
+
const body = {
|
|
797
|
+
fee: fee.toString(),
|
|
798
|
+
amount: amount.toString(),
|
|
799
|
+
side: 'buy',
|
|
800
|
+
};
|
|
801
|
+
try {
|
|
802
|
+
buyRollsOpResponse = await (0, RequestHandler_1.postRequest)(url, body);
|
|
803
|
+
}
|
|
804
|
+
catch (ex) {
|
|
805
|
+
console.error(`Thyra account: error while buying rolls: ${ex}`);
|
|
806
|
+
throw ex;
|
|
807
|
+
}
|
|
808
|
+
if (buyRollsOpResponse.isError || buyRollsOpResponse.error) {
|
|
809
|
+
throw buyRollsOpResponse.error;
|
|
810
|
+
}
|
|
811
|
+
return buyRollsOpResponse.result;
|
|
795
812
|
}
|
|
796
813
|
/**
|
|
797
814
|
* This method aims to sell rolls on behalf of the sender.
|
|
@@ -800,8 +817,25 @@ class ThyraAccount {
|
|
|
800
817
|
* @param fee - The fee to be paid for the transaction execution by the node.
|
|
801
818
|
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
802
819
|
*/
|
|
803
|
-
sellRolls(amount, fee) {
|
|
804
|
-
|
|
820
|
+
async sellRolls(amount, fee) {
|
|
821
|
+
let sellRollsOpResponse = null;
|
|
822
|
+
const url = `${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/rolls`;
|
|
823
|
+
const body = {
|
|
824
|
+
fee: fee.toString(),
|
|
825
|
+
amount: amount.toString(),
|
|
826
|
+
side: 'sell',
|
|
827
|
+
};
|
|
828
|
+
try {
|
|
829
|
+
sellRollsOpResponse = await (0, RequestHandler_1.postRequest)(url, body);
|
|
830
|
+
}
|
|
831
|
+
catch (ex) {
|
|
832
|
+
console.error(`Thyra account: error while selling rolls: ${ex}`);
|
|
833
|
+
throw ex;
|
|
834
|
+
}
|
|
835
|
+
if (sellRollsOpResponse.isError || sellRollsOpResponse.error) {
|
|
836
|
+
throw sellRollsOpResponse.error;
|
|
837
|
+
}
|
|
838
|
+
return sellRollsOpResponse.result;
|
|
805
839
|
}
|
|
806
840
|
/**
|
|
807
841
|
* This method aims to transfer MAS on behalf of the sender to a recipient.
|
|
@@ -928,7 +962,7 @@ exports.ThyraDiscovery = ThyraDiscovery;
|
|
|
928
962
|
Object.defineProperty(exports, "__esModule", {
|
|
929
963
|
value: true
|
|
930
964
|
});
|
|
931
|
-
exports.ThyraProvider = exports.THYRA_PROVIDER_NAME = exports.
|
|
965
|
+
exports.ThyraProvider = exports.THYRA_PROVIDER_NAME = exports.THYRA_URL = exports.THYRA_IMPORT_ACCOUNTS_URL = exports.THYRA_ACCOUNTS_URL = void 0;
|
|
932
966
|
const AccountDeletion_1 = require("../provider/AccountDeletion");
|
|
933
967
|
const AccountImport_1 = require("../provider/AccountImport");
|
|
934
968
|
const RequestHandler_1 = require("./RequestHandler");
|
|
@@ -936,12 +970,15 @@ const ThyraAccount_1 = require("./ThyraAccount");
|
|
|
936
970
|
/**
|
|
937
971
|
* The Thyra accounts url
|
|
938
972
|
*/
|
|
939
|
-
exports.
|
|
940
|
-
exports.THYRA_URL = 'https://my.massa';
|
|
973
|
+
exports.THYRA_ACCOUNTS_URL = 'https://my.massa/thyra/plugin/massalabs/wallet/api/accounts';
|
|
941
974
|
/**
|
|
942
975
|
* Thyra's url for importing accounts
|
|
943
976
|
*/
|
|
944
|
-
exports.
|
|
977
|
+
exports.THYRA_IMPORT_ACCOUNTS_URL = `${exports.THYRA_ACCOUNTS_URL}/import/`;
|
|
978
|
+
/**
|
|
979
|
+
* MassaStation url
|
|
980
|
+
*/
|
|
981
|
+
exports.THYRA_URL = 'https://my.massa/';
|
|
945
982
|
/**
|
|
946
983
|
* Thyra's wallet provider name
|
|
947
984
|
*/
|
|
@@ -977,7 +1014,7 @@ class ThyraProvider {
|
|
|
977
1014
|
async accounts() {
|
|
978
1015
|
let thyraAccountsResponse = null;
|
|
979
1016
|
try {
|
|
980
|
-
thyraAccountsResponse = await (0, RequestHandler_1.getRequest)(exports.
|
|
1017
|
+
thyraAccountsResponse = await (0, RequestHandler_1.getRequest)(exports.THYRA_ACCOUNTS_URL);
|
|
981
1018
|
} catch (ex) {
|
|
982
1019
|
console.error(`Thyra accounts retrieval error`);
|
|
983
1020
|
throw ex;
|
|
@@ -997,8 +1034,8 @@ class ThyraProvider {
|
|
|
997
1034
|
*
|
|
998
1035
|
* @param publicKey - The public key of the account.
|
|
999
1036
|
* @param privateKey - The private key of the account.
|
|
1000
|
-
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
1001
1037
|
*
|
|
1038
|
+
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
1002
1039
|
*/
|
|
1003
1040
|
async importAccount(publicKey, privateKey) {
|
|
1004
1041
|
const accountImportRequest = {
|
|
@@ -1043,7 +1080,7 @@ class ThyraProvider {
|
|
|
1043
1080
|
// delete the account in question
|
|
1044
1081
|
let thyraAccountsResponse = null;
|
|
1045
1082
|
try {
|
|
1046
|
-
thyraAccountsResponse = await (0, RequestHandler_1.deleteRequest)(`${exports.THYRA_ACCOUNTS_URL}
|
|
1083
|
+
thyraAccountsResponse = await (0, RequestHandler_1.deleteRequest)(`${exports.THYRA_ACCOUNTS_URL}/${accountToDelete.nickname}`);
|
|
1047
1084
|
} catch (ex) {
|
|
1048
1085
|
console.log(`Thyra accounts deletion error`, ex);
|
|
1049
1086
|
return {
|
|
@@ -1068,7 +1105,7 @@ class ThyraProvider {
|
|
|
1068
1105
|
async getNodesUrls() {
|
|
1069
1106
|
let nodesResponse = null;
|
|
1070
1107
|
try {
|
|
1071
|
-
nodesResponse = await (0, RequestHandler_1.getRequest)(`${exports.THYRA_URL}
|
|
1108
|
+
nodesResponse = await (0, RequestHandler_1.getRequest)(`${exports.THYRA_URL}massa/node`);
|
|
1072
1109
|
if (nodesResponse.isError || nodesResponse.error) {
|
|
1073
1110
|
throw nodesResponse.error.message;
|
|
1074
1111
|
}
|
|
@@ -1086,7 +1123,21 @@ class ThyraProvider {
|
|
|
1086
1123
|
* @returns a Promise that resolves to the details of the newly generated account.
|
|
1087
1124
|
*/
|
|
1088
1125
|
async generateNewAccount(name) {
|
|
1089
|
-
|
|
1126
|
+
let thyraAccountsResponse = null;
|
|
1127
|
+
console.log(exports.THYRA_ACCOUNTS_URL + '/' + name);
|
|
1128
|
+
try {
|
|
1129
|
+
thyraAccountsResponse = await (0, RequestHandler_1.postRequest)(exports.THYRA_ACCOUNTS_URL + '/' + name, {});
|
|
1130
|
+
if (thyraAccountsResponse.isError || thyraAccountsResponse.error) {
|
|
1131
|
+
throw thyraAccountsResponse.error.message;
|
|
1132
|
+
}
|
|
1133
|
+
return {
|
|
1134
|
+
address: thyraAccountsResponse.result.address,
|
|
1135
|
+
name: thyraAccountsResponse.result.nickname
|
|
1136
|
+
};
|
|
1137
|
+
} catch (ex) {
|
|
1138
|
+
console.error(`Error while generating account: ${ex}`);
|
|
1139
|
+
throw ex;
|
|
1140
|
+
}
|
|
1090
1141
|
}
|
|
1091
1142
|
}
|
|
1092
1143
|
exports.ThyraProvider = ThyraProvider;
|
|
@@ -83,7 +83,7 @@ class ThyraAccount {
|
|
|
83
83
|
async sign(data) {
|
|
84
84
|
let signOpResponse = null;
|
|
85
85
|
try {
|
|
86
|
-
signOpResponse = await (0, RequestHandler_1.postRequest)(`${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/
|
|
86
|
+
signOpResponse = await (0, RequestHandler_1.postRequest)(`${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/sign`, {
|
|
87
87
|
operation: data,
|
|
88
88
|
batch: false,
|
|
89
89
|
});
|
|
@@ -104,8 +104,25 @@ class ThyraAccount {
|
|
|
104
104
|
* @param fee - The fee to be paid for the transaction execution by the node.
|
|
105
105
|
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
106
106
|
*/
|
|
107
|
-
buyRolls(amount, fee) {
|
|
108
|
-
|
|
107
|
+
async buyRolls(amount, fee) {
|
|
108
|
+
let buyRollsOpResponse = null;
|
|
109
|
+
const url = `${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/rolls`;
|
|
110
|
+
const body = {
|
|
111
|
+
fee: fee.toString(),
|
|
112
|
+
amount: amount.toString(),
|
|
113
|
+
side: 'buy',
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
buyRollsOpResponse = await (0, RequestHandler_1.postRequest)(url, body);
|
|
117
|
+
}
|
|
118
|
+
catch (ex) {
|
|
119
|
+
console.error(`Thyra account: error while buying rolls: ${ex}`);
|
|
120
|
+
throw ex;
|
|
121
|
+
}
|
|
122
|
+
if (buyRollsOpResponse.isError || buyRollsOpResponse.error) {
|
|
123
|
+
throw buyRollsOpResponse.error;
|
|
124
|
+
}
|
|
125
|
+
return buyRollsOpResponse.result;
|
|
109
126
|
}
|
|
110
127
|
/**
|
|
111
128
|
* This method aims to sell rolls on behalf of the sender.
|
|
@@ -114,8 +131,25 @@ class ThyraAccount {
|
|
|
114
131
|
* @param fee - The fee to be paid for the transaction execution by the node.
|
|
115
132
|
* @returns An ITransactionDetails object. It contains the operationId on the network.
|
|
116
133
|
*/
|
|
117
|
-
sellRolls(amount, fee) {
|
|
118
|
-
|
|
134
|
+
async sellRolls(amount, fee) {
|
|
135
|
+
let sellRollsOpResponse = null;
|
|
136
|
+
const url = `${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/rolls`;
|
|
137
|
+
const body = {
|
|
138
|
+
fee: fee.toString(),
|
|
139
|
+
amount: amount.toString(),
|
|
140
|
+
side: 'sell',
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
sellRollsOpResponse = await (0, RequestHandler_1.postRequest)(url, body);
|
|
144
|
+
}
|
|
145
|
+
catch (ex) {
|
|
146
|
+
console.error(`Thyra account: error while selling rolls: ${ex}`);
|
|
147
|
+
throw ex;
|
|
148
|
+
}
|
|
149
|
+
if (sellRollsOpResponse.isError || sellRollsOpResponse.error) {
|
|
150
|
+
throw sellRollsOpResponse.error;
|
|
151
|
+
}
|
|
152
|
+
return sellRollsOpResponse.result;
|
|
119
153
|
}
|
|
120
154
|
/**
|
|
121
155
|
* This method aims to transfer MAS on behalf of the sender to a recipient.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThyraAccount.js","sourceRoot":"","sources":["../../src/thyra/ThyraAccount.ts"],"names":[],"mappings":";;;AAOA,qDAAgF;AAChF,mDAAqD;AAErD;;GAEG;AACH,MAAM,iBAAiB,GAAG,+DAA+D,CAAC;AA4B1F;;;;;;GAMG;AACH,MAAa,YAAY;IAKvB;;;;;;;;;;;;OAYG;IACH,YAAmB,EAAE,OAAO,EAAE,IAAI,EAAmB,EAAE,YAAoB;QACzE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GA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AAI,CAAC,KAAK,QAAQ,CAAC;QACxD,MAAM,IAAI,GAAG;YACX,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;YACnB,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;YACzB,IAAI,EAAE,MAAM;SACb,CAAC;QACF,IAAI;YACF,mBAAmB,GAAG,MAAM,IAAA,4BAAW,EAAsB,GAAG,EAAE,IAAI,CAAC,CAAC;SACzE;QAAC,OAAO,EAAE,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,EAAE,CAAC,CAAC;YACjE,MAAM,EAAE,CAAC;SACV;QACD,IAAI,mBAAmB,CAAC,OAAO,IAAI,mBAAmB,CAAC,KAAK,EAAE;YAC5D,MAAM,mBAAmB,CAAC,KAAK,CAAC;SACjC;QACD,OAAO,mBAAmB,CAAC,MAAM,CAAC;IACpC,CAAC;IAED;;;;;;OAMG;IACH,eAAe,CACb,MAAc,EACd,gBAAwB,EACxB,GAAW;QAEX,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF;AA3KD,oCA2KC"}
|
|
@@ -6,12 +6,15 @@ import { IAccountDetails } from '../account';
|
|
|
6
6
|
/**
|
|
7
7
|
* The Thyra accounts url
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const THYRA_URL = "https://my.massa";
|
|
9
|
+
export declare const THYRA_ACCOUNTS_URL = "https://my.massa/thyra/plugin/massalabs/wallet/api/accounts";
|
|
11
10
|
/**
|
|
12
11
|
* Thyra's url for importing accounts
|
|
13
12
|
*/
|
|
14
|
-
export declare const
|
|
13
|
+
export declare const THYRA_IMPORT_ACCOUNTS_URL: string;
|
|
14
|
+
/**
|
|
15
|
+
* MassaStation url
|
|
16
|
+
*/
|
|
17
|
+
export declare const THYRA_URL = "https://my.massa/";
|
|
15
18
|
/**
|
|
16
19
|
* Thyra's wallet provider name
|
|
17
20
|
*/
|
|
@@ -60,8 +63,8 @@ export declare class ThyraProvider implements IProvider {
|
|
|
60
63
|
*
|
|
61
64
|
* @param publicKey - The public key of the account.
|
|
62
65
|
* @param privateKey - The private key of the account.
|
|
63
|
-
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
64
66
|
*
|
|
67
|
+
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
65
68
|
*/
|
|
66
69
|
importAccount(publicKey: string, privateKey: string): Promise<IAccountImportResponse>;
|
|
67
70
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThyraProvider = exports.THYRA_PROVIDER_NAME = exports.
|
|
3
|
+
exports.ThyraProvider = exports.THYRA_PROVIDER_NAME = exports.THYRA_URL = exports.THYRA_IMPORT_ACCOUNTS_URL = exports.THYRA_ACCOUNTS_URL = void 0;
|
|
4
4
|
const AccountDeletion_1 = require("../provider/AccountDeletion");
|
|
5
5
|
const AccountImport_1 = require("../provider/AccountImport");
|
|
6
6
|
const RequestHandler_1 = require("./RequestHandler");
|
|
@@ -8,12 +8,15 @@ const ThyraAccount_1 = require("./ThyraAccount");
|
|
|
8
8
|
/**
|
|
9
9
|
* The Thyra accounts url
|
|
10
10
|
*/
|
|
11
|
-
exports.
|
|
12
|
-
exports.THYRA_URL = 'https://my.massa';
|
|
11
|
+
exports.THYRA_ACCOUNTS_URL = 'https://my.massa/thyra/plugin/massalabs/wallet/api/accounts';
|
|
13
12
|
/**
|
|
14
13
|
* Thyra's url for importing accounts
|
|
15
14
|
*/
|
|
16
|
-
exports.
|
|
15
|
+
exports.THYRA_IMPORT_ACCOUNTS_URL = `${exports.THYRA_ACCOUNTS_URL}/import/`;
|
|
16
|
+
/**
|
|
17
|
+
* MassaStation url
|
|
18
|
+
*/
|
|
19
|
+
exports.THYRA_URL = 'https://my.massa/';
|
|
17
20
|
/**
|
|
18
21
|
* Thyra's wallet provider name
|
|
19
22
|
*/
|
|
@@ -49,7 +52,7 @@ class ThyraProvider {
|
|
|
49
52
|
async accounts() {
|
|
50
53
|
let thyraAccountsResponse = null;
|
|
51
54
|
try {
|
|
52
|
-
thyraAccountsResponse = await (0, RequestHandler_1.getRequest)(exports.
|
|
55
|
+
thyraAccountsResponse = await (0, RequestHandler_1.getRequest)(exports.THYRA_ACCOUNTS_URL);
|
|
53
56
|
}
|
|
54
57
|
catch (ex) {
|
|
55
58
|
console.error(`Thyra accounts retrieval error`);
|
|
@@ -67,8 +70,8 @@ class ThyraProvider {
|
|
|
67
70
|
*
|
|
68
71
|
* @param publicKey - The public key of the account.
|
|
69
72
|
* @param privateKey - The private key of the account.
|
|
70
|
-
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
71
73
|
*
|
|
74
|
+
* @returns a Promise that resolves to an instance of IAccountImportResponse.
|
|
72
75
|
*/
|
|
73
76
|
async importAccount(publicKey, privateKey) {
|
|
74
77
|
const accountImportRequest = {
|
|
@@ -115,7 +118,7 @@ class ThyraProvider {
|
|
|
115
118
|
// delete the account in question
|
|
116
119
|
let thyraAccountsResponse = null;
|
|
117
120
|
try {
|
|
118
|
-
thyraAccountsResponse = await (0, RequestHandler_1.deleteRequest)(`${exports.THYRA_ACCOUNTS_URL}
|
|
121
|
+
thyraAccountsResponse = await (0, RequestHandler_1.deleteRequest)(`${exports.THYRA_ACCOUNTS_URL}/${accountToDelete.nickname}`);
|
|
119
122
|
}
|
|
120
123
|
catch (ex) {
|
|
121
124
|
console.log(`Thyra accounts deletion error`, ex);
|
|
@@ -141,7 +144,7 @@ class ThyraProvider {
|
|
|
141
144
|
async getNodesUrls() {
|
|
142
145
|
let nodesResponse = null;
|
|
143
146
|
try {
|
|
144
|
-
nodesResponse = await (0, RequestHandler_1.getRequest)(`${exports.THYRA_URL}
|
|
147
|
+
nodesResponse = await (0, RequestHandler_1.getRequest)(`${exports.THYRA_URL}massa/node`);
|
|
145
148
|
if (nodesResponse.isError || nodesResponse.error) {
|
|
146
149
|
throw nodesResponse.error.message;
|
|
147
150
|
}
|
|
@@ -160,7 +163,22 @@ class ThyraProvider {
|
|
|
160
163
|
* @returns a Promise that resolves to the details of the newly generated account.
|
|
161
164
|
*/
|
|
162
165
|
async generateNewAccount(name) {
|
|
163
|
-
|
|
166
|
+
let thyraAccountsResponse = null;
|
|
167
|
+
console.log(exports.THYRA_ACCOUNTS_URL + '/' + name);
|
|
168
|
+
try {
|
|
169
|
+
thyraAccountsResponse = await (0, RequestHandler_1.postRequest)(exports.THYRA_ACCOUNTS_URL + '/' + name, {});
|
|
170
|
+
if (thyraAccountsResponse.isError || thyraAccountsResponse.error) {
|
|
171
|
+
throw thyraAccountsResponse.error.message;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
address: thyraAccountsResponse.result.address,
|
|
175
|
+
name: thyraAccountsResponse.result.nickname,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
catch (ex) {
|
|
179
|
+
console.error(`Error while generating account: ${ex}`);
|
|
180
|
+
throw ex;
|
|
181
|
+
}
|
|
164
182
|
}
|
|
165
183
|
}
|
|
166
184
|
exports.ThyraProvider = ThyraProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThyraProvider.js","sourceRoot":"","sources":["../../src/thyra/ThyraProvider.ts"],"names":[],"mappings":";;;AAAA,iEAGqC;AACrC,6DAImC;AAEnC,qDAM0B;AAC1B,iDAA8C;AAI9C;;GAEG;AACU,QAAA,
|
|
1
|
+
{"version":3,"file":"ThyraProvider.js","sourceRoot":"","sources":["../../src/thyra/ThyraProvider.ts"],"names":[],"mappings":";;;AAAA,iEAGqC;AACrC,6DAImC;AAEnC,qDAM0B;AAC1B,iDAA8C;AAI9C;;GAEG;AACU,QAAA,kBAAkB,GAC7B,6DAA6D,CAAC;AAEhE;;GAEG;AACU,QAAA,yBAAyB,GAAG,GAAG,0BAAkB,UAAU,CAAC;AAEzE;;GAEG;AACU,QAAA,SAAS,GAAG,mBAAmB,CAAC;AAE7C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