@reyaxyz/wallet-sdk 0.1.5 → 0.1.7
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/clients/helpers/constants.js +5 -2
- package/dist/clients/helpers/constants.js.map +1 -1
- package/dist/clients/modules/tos/index.js +5 -3
- package/dist/clients/modules/tos/index.js.map +1 -1
- package/dist/clients/wallet-client.js +1 -1
- package/dist/clients/wallet-client.js.map +1 -1
- package/dist/types/clients/helpers/constants.d.ts +2 -1
- package/dist/types/clients/helpers/constants.d.ts.map +1 -1
- package/dist/types/clients/modules/tos/index.d.ts +2 -0
- package/dist/types/clients/modules/tos/index.d.ts.map +1 -1
- package/dist/types/clients/wallet-client.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/helpers/constants.ts +6 -2
- package/src/clients/modules/tos/index.ts +8 -1
- package/src/clients/wallet-client.ts +1 -0
|
@@ -7,6 +7,7 @@ exports.API_CLIENT_CONFIGS = {
|
|
|
7
7
|
chain: common_1.ReyaChainId.reyaCronos,
|
|
8
8
|
apiEndpoint: 'http://localhost:3000',
|
|
9
9
|
trmApiEndpoint: 'https://api.trmlabs.com',
|
|
10
|
+
tosUrl: '',
|
|
10
11
|
environment: 'local',
|
|
11
12
|
timeout: common_1.API_TIMEOUT,
|
|
12
13
|
},
|
|
@@ -14,6 +15,7 @@ exports.API_CLIENT_CONFIGS = {
|
|
|
14
15
|
chain: common_1.ReyaChainId.reyaNetwork,
|
|
15
16
|
apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
16
17
|
trmApiEndpoint: 'https://api.trmlabs.com',
|
|
18
|
+
tosUrl: '',
|
|
17
19
|
environment: 'production',
|
|
18
20
|
timeout: common_1.API_TIMEOUT,
|
|
19
21
|
},
|
|
@@ -21,6 +23,7 @@ exports.API_CLIENT_CONFIGS = {
|
|
|
21
23
|
chain: common_1.ReyaChainId.reyaCronos,
|
|
22
24
|
apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
23
25
|
trmApiEndpoint: 'https://api.trmlabs.com',
|
|
26
|
+
tosUrl: '',
|
|
24
27
|
environment: 'test',
|
|
25
28
|
timeout: common_1.API_TIMEOUT,
|
|
26
29
|
},
|
|
@@ -29,8 +32,8 @@ exports.API_CLIENT_CONFIGS = {
|
|
|
29
32
|
* Returns the terms of service text that users have to agree to connect their wallet.
|
|
30
33
|
* Note - Any changes, including whitespace, will mean a new signature is required.
|
|
31
34
|
*/
|
|
32
|
-
var getToSText = function () {
|
|
33
|
-
var text = "\nPlease sign this message to log in. This won't cost you any ETH.\n\nBy signing, you accept Voltz's Terms of Service (which may have been updated since you last signed). You can find these here:\n".concat(
|
|
35
|
+
var getToSText = function (tosUrl) {
|
|
36
|
+
var text = "\nPlease sign this message to log in. This won't cost you any ETH.\n\nBy signing, you accept Voltz's Terms of Service (which may have been updated since you last signed). You can find these here:\n".concat(tosUrl, "\n\nIf you're connecting a hardware wallet, you'll need to sign the message on your device too.");
|
|
34
37
|
return text.trim();
|
|
35
38
|
};
|
|
36
39
|
exports.getToSText = getToSText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,0CAA2D;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,0CAA2D;AAY9C,QAAA,kBAAkB,GAA8C;IAC3E,KAAK,EAAE;QACL,KAAK,EAAE,oBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,uBAAuB;QACpC,cAAc,EAAE,yBAAyB;QACzC,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,oBAAW;KACrB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,oBAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,kDAAkD;QAC/D,cAAc,EAAE,yBAAyB;QACzC,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,YAAY;QACzB,OAAO,EAAE,oBAAW;KACrB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,oBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,kDAAkD;QAC/D,cAAc,EAAE,yBAAyB;QACzC,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,MAAM;QACnB,OAAO,EAAE,oBAAW;KACrB;CACF,CAAC;AAEF;;;GAGG;AACI,IAAM,UAAU,GAAG,UAAC,MAAc;IACvC,IAAM,IAAI,GAAG,+MAIb,MAAM,oGAEoF,CAAC;IAE3F,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;AACrB,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB","sourcesContent":["import { API_TIMEOUT, ReyaChainId } from '@reyaxyz/common';\n\ntype ServiceEnvironment = 'production' | 'test' | 'local';\nexport interface ServiceConfig {\n chain: ReyaChainId;\n apiEndpoint: string;\n trmApiEndpoint: string;\n tosUrl: string;\n environment: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API\n timeout: number; // Optional timeout for API requests\n}\n\nexport const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {\n local: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: 'http://localhost:3000',\n trmApiEndpoint: 'https://api.trmlabs.com',\n tosUrl: '',\n environment: 'local',\n timeout: API_TIMEOUT,\n },\n production: {\n chain: ReyaChainId.reyaNetwork,\n apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n trmApiEndpoint: 'https://api.trmlabs.com',\n tosUrl: '',\n environment: 'production',\n timeout: API_TIMEOUT,\n },\n test: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n trmApiEndpoint: 'https://api.trmlabs.com',\n tosUrl: '',\n environment: 'test',\n timeout: API_TIMEOUT,\n },\n};\n\n/**\n * Returns the terms of service text that users have to agree to connect their wallet.\n * Note - Any changes, including whitespace, will mean a new signature is required.\n */\nexport const getToSText = (tosUrl: string) => {\n const text = `\nPlease sign this message to log in. This won't cost you any ETH.\n\nBy signing, you accept Voltz's Terms of Service (which may have been updated since you last signed). You can find these here:\n${tosUrl}\n\nIf you're connecting a hardware wallet, you'll need to sign the message on your device too.`;\n\n return text.trim();\n};\n"]}
|
|
@@ -55,8 +55,10 @@ var common_1 = require("@reyaxyz/common");
|
|
|
55
55
|
var constants_1 = require("../../helpers/constants");
|
|
56
56
|
var ToSSignatureClient = /** @class */ (function (_super) {
|
|
57
57
|
__extends(ToSSignatureClient, _super);
|
|
58
|
-
function ToSSignatureClient() {
|
|
59
|
-
|
|
58
|
+
function ToSSignatureClient(tosUrl, host, apiTimeout) {
|
|
59
|
+
var _this = _super.call(this, host, apiTimeout) || this;
|
|
60
|
+
_this.tosUrl = tosUrl;
|
|
61
|
+
return _this;
|
|
60
62
|
}
|
|
61
63
|
ToSSignatureClient.prototype.getSignature = function (walletAddress) {
|
|
62
64
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -97,7 +99,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
|
|
|
97
99
|
return [4 /*yield*/, this.getSignature(signerAddress)];
|
|
98
100
|
case 2:
|
|
99
101
|
signatureData = _a.sent();
|
|
100
|
-
latestToS = (0, constants_1.getToSText)();
|
|
102
|
+
latestToS = (0, constants_1.getToSText)(this.tosUrl);
|
|
101
103
|
termsAccepted = false;
|
|
102
104
|
if (signatureData &&
|
|
103
105
|
signatureData.walletAddress.toLowerCase() ===
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AAEzB,qDAAqD;AAErD;IAAgD,sCAAU;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/mod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CAAC,CAAC;wBACtC,aAAa,GAAG,KAAK,CAAC;wBAE1B,IACE,aAAa;4BACb,aAAa,CAAC,aAAa,CAAC,WAAW,EAAE;gCACvC,aAAa,CAAC,WAAW,EAAE;4BAC7B,aAAa,CAAC,OAAO,KAAK,SAAS,EACnC,CAAC;4BACD,+CAA+C;4BAC/C,2DAA2D;4BAC3D,aAAa,GAAG,IAAI,CAAC;wBACvB,CAAC,CAAC,4BAA4B;6BAE1B,CAAC,aAAa,EAAd,wBAAc;;;;wBAGI,qBAAM,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAA;;wBAAtD,SAAS,GAAG,SAA0C;wBAC3C,qBAAM,IAAI,CAAC,oBAAoB,CAC9C,aAAa,EACb,SAAS,EACT,SAAS,CACV,EAAA;;wBAJK,QAAQ,GAAG,SAIhB;wBAED,IAAI,CAAC,QAAQ,CAAC,0BAA0B,EAAE,CAAC;4BACzC,4BAA4B;4BAC5B,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;wBAC5C,CAAC;;;;wBAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;;;;;KAGnD;IACH,yBAAC;AAAD,CAAC,AAvED,CAAgD,mBAAU,GAuEzD","sourcesContent":["import {\n Address,\n RestClient,\n SignatureData,\n SaveSignatureResult,\n} from '@reyaxyz/common';\nimport { CheckForToSSignatureParams } from './types';\nimport { getToSText } from '../../helpers/constants';\n\nexport default class ToSSignatureClient extends RestClient {\n readonly tosUrl: string;\n\n constructor(tosUrl: string, host: string, apiTimeout?: number | null) {\n super(host, apiTimeout);\n this.tosUrl = tosUrl;\n }\n\n private async getSignature(\n walletAddress: Address,\n ): Promise<SignatureData | undefined> {\n const uri = `/owner/${walletAddress}/tos/get-signature`;\n // todo: make sure get api returns undefined if not found\n return await this.get(uri);\n }\n\n private async saveSignatureWithToS(\n walletAddress: Address,\n signature: string,\n termsOfService: string,\n ): Promise<SaveSignatureResult> {\n // Build formData object.\n const formData = new FormData();\n formData.append('signature', signature);\n formData.append('walletAddress', walletAddress);\n formData.append('message', termsOfService);\n\n const uri = '/owner/tos/add-signature';\n return this.post(uri, undefined, formData, undefined);\n }\n\n async checkForToSSignature(params: CheckForToSSignatureParams) {\n const signerAddress = (\n await params.signer.getAddress()\n ).toLowerCase() as Address;\n\n const signatureData = await this.getSignature(signerAddress);\n\n const latestToS = getToSText(this.tosUrl);\n let termsAccepted = false;\n\n if (\n signatureData &&\n signatureData.walletAddress.toLowerCase() ===\n signerAddress.toLowerCase() &&\n signatureData.message === latestToS\n ) {\n // Wallet matches, and signed data also matches\n // (signature was checked before being written to database)\n termsAccepted = true;\n } // todo: do we want eip1271?\n\n if (!termsAccepted) {\n try {\n // The latest terms of service have not been accepted. Get a signature now.\n const signature = await params.signer.signMessage(latestToS);\n const response = await this.saveSignatureWithToS(\n signerAddress,\n signature,\n latestToS,\n );\n\n if (!response.signatureSavedSuccessfully) {\n // todo: do we want eip1271?\n throw new Error('Error saving signature');\n }\n } catch (error) {\n throw new Error('Error processing signature');\n }\n }\n }\n}\n"]}
|
|
@@ -13,7 +13,7 @@ var tos_1 = __importDefault(require("./modules/tos"));
|
|
|
13
13
|
var WalletClient = /** @class */ (function () {
|
|
14
14
|
function WalletClient() {
|
|
15
15
|
this._riskClient = new risk_1.default(WalletClient.config.trmApiEndpoint);
|
|
16
|
-
this._tosSignatureClient = new tos_1.default(WalletClient.config.apiEndpoint);
|
|
16
|
+
this._tosSignatureClient = new tos_1.default(WalletClient.config.tosUrl, WalletClient.config.apiEndpoint);
|
|
17
17
|
}
|
|
18
18
|
WalletClient.configure = function (environment) {
|
|
19
19
|
WalletClient.config =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-client.js","sourceRoot":"/","sources":["clients/wallet-client.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwE;AAExE,wDAAwC;AACxC,sDAA+C;AAC/C;;GAEG;AACH;IAME;QACE,IAAI,CAAC,WAA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CAAC,cAAc,CAAC,CAAC;QACtE,IAAI,CAAC,mBAAmB,GAAG,IAAI,aAAkB,CAC/C,YAAY,CAAC,MAAM,CAAC,MAAM,EAC1B,YAAY,CAAC,MAAM,CAAC,WAAW,CAChC,CAAC;IACJ,CAAC;IAEa,sBAAS,GAAvB,UAAwB,WAAyC;QAC/D,YAAY,CAAC,MAAM;YACjB,8BAAkB,CAAC,WAAW,CAAC,IAAI,8BAAkB,CAAC,MAAM,CAAC,CAAC;QAChE,YAAY,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IAC7C,CAAC;IAEc,wBAAW,GAA1B;QACE,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;QACJ,CAAC;QACD,OAAO,YAAY,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,sBAAkB,uBAAO;aAAzB;YACE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACpD,CAAC;YACD,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;QACnC,CAAC;;;OAAA;IASD,sBAAkB,uBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC;QAChD,CAAC;;;OAAA;IASD,sBAAkB,4BAAY;QAP9B;;;;;;WAMG;aACH;YACE,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC,mBAAmB,CAAC;QACxD,CAAC;;;OAAA;IAtDc,mBAAM,GAAkB,8BAAkB,CAAC,MAAM,CAAC,CAAC;IAuDpE,mBAAC;CAAA,AAzDD,IAyDC;AAzDY,oCAAY","sourcesContent":["import { API_CLIENT_CONFIGS, ServiceConfig } from './helpers/constants';\nimport { ReyaChainId } from '@reyaxyz/common';\nimport RiskClient from './modules/risk';\nimport ToSSignatureClient from './modules/tos';\n/**\n * @description Client for Wallet\n */\nexport class WalletClient {\n private static instance: WalletClient;\n private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];\n private readonly _riskClient: RiskClient;\n private readonly _tosSignatureClient: ToSSignatureClient;\n\n private constructor() {\n this._riskClient = new RiskClient(WalletClient.config.trmApiEndpoint);\n this._tosSignatureClient = new ToSSignatureClient(\n WalletClient.config.tosUrl,\n WalletClient.config.apiEndpoint,\n );\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n WalletClient.config =\n API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n WalletClient.instance = new WalletClient();\n }\n\n private static getInstance(): WalletClient {\n if (!WalletClient.instance) {\n throw new Error(\n 'WalletClient is not configured. Please configure it before using.',\n );\n }\n return WalletClient.instance;\n }\n\n public static get network(): ReyaChainId {\n if (!WalletClient.config.chain) {\n throw new Error('WalletClient is not configured');\n }\n return WalletClient.config.chain;\n }\n\n /**\n * Provides access to the RiskClient instance.\n * This getter allows for interacting with risk-related API functionalities.\n *\n * @returns {RiskClient} An instance of RiskClient for account-related operations.\n * @memberof WalletClient\n */\n public static get account(): RiskClient {\n return WalletClient.getInstance()._riskClient;\n }\n\n /**\n * Provides access to the ToSSignatureClient instance.\n * This getter allows for interacting with tos signature related API functionalities.\n *\n * @returns {ToSSignatureClient} An instance of ToSSignatureClient for account-related operations.\n * @memberof WalletClient\n */\n public static get tosSignature(): ToSSignatureClient {\n return WalletClient.getInstance()._tosSignatureClient;\n }\n}\n"]}
|
|
@@ -4,6 +4,7 @@ export interface ServiceConfig {
|
|
|
4
4
|
chain: ReyaChainId;
|
|
5
5
|
apiEndpoint: string;
|
|
6
6
|
trmApiEndpoint: string;
|
|
7
|
+
tosUrl: string;
|
|
7
8
|
environment: ServiceEnvironment;
|
|
8
9
|
timeout: number;
|
|
9
10
|
}
|
|
@@ -12,6 +13,6 @@ export declare const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfi
|
|
|
12
13
|
* Returns the terms of service text that users have to agree to connect their wallet.
|
|
13
14
|
* Note - Any changes, including whitespace, will mean a new signature is required.
|
|
14
15
|
*/
|
|
15
|
-
export declare const getToSText: () => string;
|
|
16
|
+
export declare const getToSText: (tosUrl: string) => string;
|
|
16
17
|
export {};
|
|
17
18
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3D,KAAK,kBAAkB,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAC1D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3D,KAAK,kBAAkB,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAC1D,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAyBxE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,WAAY,MAAM,WAUxC,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { RestClient } from '@reyaxyz/common';
|
|
2
2
|
import { CheckForToSSignatureParams } from './types';
|
|
3
3
|
export default class ToSSignatureClient extends RestClient {
|
|
4
|
+
readonly tosUrl: string;
|
|
5
|
+
constructor(tosUrl: string, host: string, apiTimeout?: number | null);
|
|
4
6
|
private getSignature;
|
|
5
7
|
private saveSignatureWithToS;
|
|
6
8
|
checkForToSSignature(params: CheckForToSSignatureParams): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAGrD,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAGrD,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;YAKtD,YAAY;YAQZ,oBAAoB;IAe5B,oBAAoB,CAAC,MAAM,EAAE,0BAA0B;CAwC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-client.d.ts","sourceRoot":"/","sources":["clients/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,kBAAkB,MAAM,eAAe,CAAC;AAC/C;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,MAAM,CAAC,MAAM,CAA6C;IAClE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;IAEzD,OAAO;
|
|
1
|
+
{"version":3,"file":"wallet-client.d.ts","sourceRoot":"/","sources":["clients/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,kBAAkB,MAAM,eAAe,CAAC;AAC/C;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,MAAM,CAAC,MAAM,CAA6C;IAClE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;IAEzD,OAAO;WAQO,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,IAAI;IAMxE,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B,WAAkB,OAAO,IAAI,WAAW,CAKvC;IAED;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,UAAU,CAEtC;IAED;;;;;;OAMG;IACH,WAAkB,YAAY,IAAI,kBAAkB,CAEnD;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/wallet-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.
|
|
36
|
+
"@reyaxyz/common": "0.32.0",
|
|
37
37
|
"axios": "^1.6.2",
|
|
38
38
|
"bignumber.js": "^9.1.2",
|
|
39
39
|
"ethers": "6.9.0"
|
|
40
40
|
},
|
|
41
41
|
"packageManager": "pnpm@8.10.4",
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "61e86b6c82a2fd2a8df1e9a4cd55092fdd7a5411"
|
|
43
43
|
}
|
|
@@ -5,6 +5,7 @@ export interface ServiceConfig {
|
|
|
5
5
|
chain: ReyaChainId;
|
|
6
6
|
apiEndpoint: string;
|
|
7
7
|
trmApiEndpoint: string;
|
|
8
|
+
tosUrl: string;
|
|
8
9
|
environment: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API
|
|
9
10
|
timeout: number; // Optional timeout for API requests
|
|
10
11
|
}
|
|
@@ -14,6 +15,7 @@ export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
|
|
|
14
15
|
chain: ReyaChainId.reyaCronos,
|
|
15
16
|
apiEndpoint: 'http://localhost:3000',
|
|
16
17
|
trmApiEndpoint: 'https://api.trmlabs.com',
|
|
18
|
+
tosUrl: '',
|
|
17
19
|
environment: 'local',
|
|
18
20
|
timeout: API_TIMEOUT,
|
|
19
21
|
},
|
|
@@ -21,6 +23,7 @@ export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
|
|
|
21
23
|
chain: ReyaChainId.reyaNetwork,
|
|
22
24
|
apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
23
25
|
trmApiEndpoint: 'https://api.trmlabs.com',
|
|
26
|
+
tosUrl: '',
|
|
24
27
|
environment: 'production',
|
|
25
28
|
timeout: API_TIMEOUT,
|
|
26
29
|
},
|
|
@@ -28,6 +31,7 @@ export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
|
|
|
28
31
|
chain: ReyaChainId.reyaCronos,
|
|
29
32
|
apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
|
|
30
33
|
trmApiEndpoint: 'https://api.trmlabs.com',
|
|
34
|
+
tosUrl: '',
|
|
31
35
|
environment: 'test',
|
|
32
36
|
timeout: API_TIMEOUT,
|
|
33
37
|
},
|
|
@@ -37,12 +41,12 @@ export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
|
|
|
37
41
|
* Returns the terms of service text that users have to agree to connect their wallet.
|
|
38
42
|
* Note - Any changes, including whitespace, will mean a new signature is required.
|
|
39
43
|
*/
|
|
40
|
-
export const getToSText = () => {
|
|
44
|
+
export const getToSText = (tosUrl: string) => {
|
|
41
45
|
const text = `
|
|
42
46
|
Please sign this message to log in. This won't cost you any ETH.
|
|
43
47
|
|
|
44
48
|
By signing, you accept Voltz's Terms of Service (which may have been updated since you last signed). You can find these here:
|
|
45
|
-
${
|
|
49
|
+
${tosUrl}
|
|
46
50
|
|
|
47
51
|
If you're connecting a hardware wallet, you'll need to sign the message on your device too.`;
|
|
48
52
|
|
|
@@ -8,6 +8,13 @@ import { CheckForToSSignatureParams } from './types';
|
|
|
8
8
|
import { getToSText } from '../../helpers/constants';
|
|
9
9
|
|
|
10
10
|
export default class ToSSignatureClient extends RestClient {
|
|
11
|
+
readonly tosUrl: string;
|
|
12
|
+
|
|
13
|
+
constructor(tosUrl: string, host: string, apiTimeout?: number | null) {
|
|
14
|
+
super(host, apiTimeout);
|
|
15
|
+
this.tosUrl = tosUrl;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
private async getSignature(
|
|
12
19
|
walletAddress: Address,
|
|
13
20
|
): Promise<SignatureData | undefined> {
|
|
@@ -38,7 +45,7 @@ export default class ToSSignatureClient extends RestClient {
|
|
|
38
45
|
|
|
39
46
|
const signatureData = await this.getSignature(signerAddress);
|
|
40
47
|
|
|
41
|
-
const latestToS = getToSText();
|
|
48
|
+
const latestToS = getToSText(this.tosUrl);
|
|
42
49
|
let termsAccepted = false;
|
|
43
50
|
|
|
44
51
|
if (
|