@reyaxyz/wallet-sdk 0.10.1 → 0.11.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.
Files changed (30) hide show
  1. package/dist/clients/modules/risk/index.js +14 -2
  2. package/dist/clients/modules/risk/index.js.map +1 -1
  3. package/dist/clients/modules/tos/index.js +25 -6
  4. package/dist/clients/modules/tos/index.js.map +1 -1
  5. package/dist/clients/modules/tos-app/index.js +23 -2
  6. package/dist/clients/modules/tos-app/index.js.map +1 -1
  7. package/dist/clients/modules/tos-app/types.js.map +1 -1
  8. package/dist/clients/wallet-client.js +6 -6
  9. package/dist/clients/wallet-client.js.map +1 -1
  10. package/dist/types/clients/modules/risk/index.d.ts +4 -2
  11. package/dist/types/clients/modules/risk/index.d.ts.map +1 -1
  12. package/dist/types/clients/modules/tos/index.d.ts +4 -2
  13. package/dist/types/clients/modules/tos/index.d.ts.map +1 -1
  14. package/dist/types/clients/modules/tos-app/index.d.ts +4 -1
  15. package/dist/types/clients/modules/tos-app/index.d.ts.map +1 -1
  16. package/dist/types/clients/modules/tos-app/types.d.ts +4 -4
  17. package/dist/types/clients/modules/tos-app/types.d.ts.map +1 -1
  18. package/dist/types/clients/wallet-client.d.ts +1 -2
  19. package/dist/types/clients/wallet-client.d.ts.map +1 -1
  20. package/package.json +3 -3
  21. package/src/clients/modules/risk/index.ts +15 -2
  22. package/src/clients/modules/tos/index.ts +20 -8
  23. package/src/clients/modules/tos-app/index.ts +17 -2
  24. package/src/clients/modules/tos-app/types.ts +4 -4
  25. package/src/clients/wallet-client.ts +11 -3
  26. package/dist/clients/helpers/constants.js +0 -25
  27. package/dist/clients/helpers/constants.js.map +0 -1
  28. package/dist/types/clients/helpers/constants.d.ts +0 -11
  29. package/dist/types/clients/helpers/constants.d.ts.map +0 -1
  30. package/src/clients/helpers/constants.ts +0 -30
@@ -14,6 +14,12 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
17
23
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
24
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
25
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -55,8 +61,11 @@ var common_1 = require("@reyaxyz/common");
55
61
  var isWalletRisky_1 = require("../../helpers/isWalletRisky");
56
62
  var RiskClient = /** @class */ (function (_super) {
57
63
  __extends(RiskClient, _super);
58
- function RiskClient() {
59
- return _super !== null && _super.apply(this, arguments) || this;
64
+ function RiskClient(apiUrl, loggingEnabled) {
65
+ var _this = _super.call(this, apiUrl) || this;
66
+ _this.loggingEnabled = false;
67
+ _this.loggingEnabled = loggingEnabled;
68
+ return _this;
60
69
  }
61
70
  RiskClient.prototype.checkForRiskWallet = function (params) {
62
71
  return __awaiter(this, void 0, void 0, function () {
@@ -79,6 +88,9 @@ var RiskClient = /** @class */ (function (_super) {
79
88
  });
80
89
  });
81
90
  };
91
+ __decorate([
92
+ (0, common_1.Logger)('RiskClient.checkForRiskWallet')
93
+ ], RiskClient.prototype, "checkForRiskWallet", null);
82
94
  return RiskClient;
83
95
  }(common_1.RestClient));
84
96
  exports.default = RiskClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/risk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAgE;AAChE,6DAA4D;AAI5D;IAAwC,8BAAU;IAAlD;;IAaA,CAAC;IAZO,uCAAkB,GAAxB,UACE,MAAiC;;;;;;wBAE3B,GAAG,GAAG,oCAA6B,MAAM,CAAC,aAAa,CAAE,CAAC;wBACvB,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;wBAAtD,WAAW,GAAwB,SAAmB;wBAE5D,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;4BAC7B,sBAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAC,CAAC,wBAAwB;wBACpD,CAAC;6BAAM,CAAC;4BACN,sBAAO,EAAE,MAAM,EAAE,CAAC,IAAA,6BAAa,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,EAAC;wBACpD,CAAC;;;;;KACF;IACH,iBAAC;AAAD,CAAC,AAbD,CAAwC,mBAAU,GAajD","sourcesContent":["import { RestClient, TRMRiskAssessment } from '@reyaxyz/common';\nimport { isWalletRisky } from '../../helpers/isWalletRisky';\n\nimport { CheckForRiskWalletResult, CheckForRiskyWalletParams } from './types';\n\nexport default class RiskClient extends RestClient {\n async checkForRiskWallet(\n params: CheckForRiskyWalletParams,\n ): Promise<CheckForRiskWalletResult> {\n const uri = `/api/tos/risk-assessments/${params.walletAddress}`;\n const assessments: TRMRiskAssessment[] = await this.get(uri);\n\n if (assessments.length === 0) {\n return { isSafe: false }; // this means TRM failed\n } else {\n return { isSafe: !isWalletRisky(assessments[0]) };\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/risk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AACzB,6DAA4D;AAI5D;IAAwC,8BAAU;IAGhD,oBAAY,MAAc,EAAE,cAAuB;QACjD,YAAA,MAAK,YAAC,MAAM,CAAC,SAAC;QAHhB,oBAAc,GAAY,KAAK,CAAC;QAI9B,KAAI,CAAC,cAAc,GAAG,cAAc,CAAC;;IACvC,CAAC;IAGK,uCAAkB,GAAlB,UACJ,MAAiC;;;;;;wBAE3B,GAAG,GAAG,oCAA6B,MAAM,CAAC,aAAa,CAAE,CAAC;wBACvB,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;wBAAtD,WAAW,GAAwB,SAAmB;wBAE5D,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;4BAC7B,sBAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAC,CAAC,wBAAwB;wBACpD,CAAC;6BAAM,CAAC;4BACN,sBAAO,EAAE,MAAM,EAAE,CAAC,IAAA,6BAAa,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,EAAC;wBACpD,CAAC;;;;;KACF;IAXK;QADL,IAAA,eAAM,EAAC,+BAA+B,CAAC;wDAYvC;IACH,iBAAC;CAAA,AArBD,CAAwC,mBAAU,GAqBjD;kBArBoB,UAAU","sourcesContent":["import {\n Loggable,\n Logger,\n RestClient,\n TRMRiskAssessment,\n} from '@reyaxyz/common';\nimport { isWalletRisky } from '../../helpers/isWalletRisky';\n\nimport { CheckForRiskWalletResult, CheckForRiskyWalletParams } from './types';\n\nexport default class RiskClient extends RestClient implements Loggable {\n loggingEnabled: boolean = false;\n\n constructor(apiUrl: string, loggingEnabled: boolean) {\n super(apiUrl);\n this.loggingEnabled = loggingEnabled;\n }\n\n @Logger('RiskClient.checkForRiskWallet')\n async checkForRiskWallet(\n params: CheckForRiskyWalletParams,\n ): Promise<CheckForRiskWalletResult> {\n const uri = `/api/tos/risk-assessments/${params.walletAddress}`;\n const assessments: TRMRiskAssessment[] = await this.get(uri);\n\n if (assessments.length === 0) {\n return { isSafe: false }; // this means TRM failed\n } else {\n return { isSafe: !isWalletRisky(assessments[0]) };\n }\n }\n}\n"]}
@@ -14,6 +14,12 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
17
23
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
24
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
25
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -54,8 +60,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
54
60
  var common_1 = require("@reyaxyz/common");
55
61
  var ToSSignatureClient = /** @class */ (function (_super) {
56
62
  __extends(ToSSignatureClient, _super);
57
- function ToSSignatureClient() {
58
- return _super !== null && _super.apply(this, arguments) || this;
63
+ function ToSSignatureClient(apiUrl, loggingEnabled) {
64
+ var _this = _super.call(this, apiUrl) || this;
65
+ _this.loggingEnabled = false;
66
+ _this.loggingEnabled = loggingEnabled;
67
+ return _this;
59
68
  }
60
69
  ToSSignatureClient.prototype.getSignature = function (walletAddress) {
61
70
  return __awaiter(this, void 0, void 0, function () {
@@ -94,7 +103,9 @@ var ToSSignatureClient = /** @class */ (function (_super) {
94
103
  formData.append('walletAddress', walletAddress);
95
104
  formData.append('message', termsOfService);
96
105
  formData.append('version', version);
97
- formData.append('referredByWalletAddress', referredByWalletAddress);
106
+ if (referredByWalletAddress) {
107
+ formData.append('referredByWalletAddress', referredByWalletAddress);
108
+ }
98
109
  uri = '/api/owner/tos/add-signature';
99
110
  return [2 /*return*/, this.post(uri, undefined, formData, undefined)];
100
111
  });
@@ -145,7 +156,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
145
156
  };
146
157
  ToSSignatureClient.prototype.signTac = function (params) {
147
158
  return __awaiter(this, void 0, void 0, function () {
148
- var latestToS, signerAddress, referredByWalletAddress, modifiedText, signature, response, error_1;
159
+ var latestToS, signerAddress, modifiedText, signature, response, error_1;
149
160
  return __generator(this, function (_a) {
150
161
  switch (_a.label) {
151
162
  case 0: return [4 /*yield*/, this.getLatestToSVersion()];
@@ -154,7 +165,6 @@ var ToSSignatureClient = /** @class */ (function (_super) {
154
165
  return [4 /*yield*/, params.signer.getAddress()];
155
166
  case 2:
156
167
  signerAddress = (_a.sent()).toLowerCase();
157
- referredByWalletAddress = (params.referredByWalletAddress || 'none').toLowerCase();
158
168
  _a.label = 3;
159
169
  case 3:
160
170
  _a.trys.push([3, 6, , 7]);
@@ -163,7 +173,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
163
173
  return [4 /*yield*/, params.signer.signMessage(modifiedText)];
164
174
  case 4:
165
175
  signature = _a.sent();
166
- return [4 /*yield*/, this.saveSignatureWithToS(signerAddress, signature, modifiedText, latestToS.version, referredByWalletAddress)];
176
+ return [4 /*yield*/, this.saveSignatureWithToS(signerAddress, signature, modifiedText, latestToS.version, params.referredByWalletAddress)];
167
177
  case 5:
168
178
  response = _a.sent();
169
179
  if (!response.signatureSavedSuccessfully) {
@@ -179,6 +189,15 @@ var ToSSignatureClient = /** @class */ (function (_super) {
179
189
  });
180
190
  });
181
191
  };
192
+ __decorate([
193
+ (0, common_1.Logger)('ToSSignatureClient.getLatestTacService')
194
+ ], ToSSignatureClient.prototype, "getLatestTacService", null);
195
+ __decorate([
196
+ (0, common_1.Logger)('ToSSignatureClient.getWalletLatestTacStatus')
197
+ ], ToSSignatureClient.prototype, "getWalletLatestTacStatus", null);
198
+ __decorate([
199
+ (0, common_1.Logger)('ToSSignatureClient.signTac')
200
+ ], ToSSignatureClient.prototype, "signTac", null);
182
201
  return ToSSignatureClient;
183
202
  }(common_1.RestClient));
184
203
  exports.default = ToSSignatureClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AAQzB;IAAgD,sCAAU;IAA1D;;IAiGA,CAAC;IAhGe,yCAAY,GAA1B,UACE,aAAsB;;;;;;wBAEhB,GAAG,GAAG,qBAAc,aAAa,uBAAoB,CAAC;wBAErD,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;oBAD1B,yDAAyD;oBACzD,sBAAO,SAAmB,EAAC;;;;KAC5B;IAEa,gDAAmB,GAAjC;;;;;;wBACQ,GAAG,GAAG,yBAAyB,CAAC;wBAC/B,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;4BAA1B,sBAAO,SAAmB,EAAC;;;;KAC5B;IAEa,iDAAoB,GAAlC,UACE,aAAsB,EACtB,SAAiB,EACjB,cAAsB,EACtB,OAAe,EACf,uBAA+B;;;;gBAGzB,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAChC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;gBACxC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;gBAChD,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;gBAC3C,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBACpC,QAAQ,CAAC,MAAM,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;gBAE9D,GAAG,GAAG,8BAA8B,CAAC;gBAC3C,sBAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAC;;;KACvD;IAEK,gDAAm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AAG,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,6CAA6C;wBAC/E,qBAAM,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,EAAA;;wBAAzD,SAAS,GAAG,SAA6C;wBAC9C,qBAAM,IAAI,CAAC,oBAAoB,CAC9C,aAAa,EACb,SAAS,EACT,YAAY,EACZ,SAAS,CAAC,OAAO,EACjB,uBAAuB,CACxB,EAAA;;wBANK,QAAQ,GAAG,SAMhB;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;;;;;KAEjD;IACH,yBAAC;AAAD,CAAC,AAjGD,CAAgD,mBAAU,GAiGzD","sourcesContent":["import {\n Address,\n RestClient,\n SignatureData,\n SaveSignatureResult,\n ToSVersionDetails,\n} from '@reyaxyz/common';\nimport {\n GetLatestTacResult,\n GetWalletLatestTacStatusParams,\n GetWalletLatestTacStatusResult,\n SignTacParams,\n} from './types';\n\nexport default class ToSSignatureClient extends RestClient {\n private async getSignature(\n walletAddress: Address,\n ): Promise<SignatureData | undefined> {\n const uri = `/api/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 getLatestToSVersion(): Promise<ToSVersionDetails> {\n const uri = `/api/tos/latest-version`;\n return await this.get(uri);\n }\n\n private async saveSignatureWithToS(\n walletAddress: Address,\n signature: string,\n termsOfService: string,\n version: string,\n referredByWalletAddress: 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 formData.append('version', version);\n formData.append('referredByWalletAddress', referredByWalletAddress);\n\n const uri = '/api/owner/tos/add-signature';\n return this.post(uri, undefined, formData, undefined);\n }\n\n async getLatestTacService(): Promise<GetLatestTacResult> {\n const tosDetails = await this.getLatestToSVersion();\n return {\n version: tosDetails.version,\n text: tosDetails.text,\n };\n }\n\n async getWalletLatestTacStatus(\n params: GetWalletLatestTacStatusParams,\n ): Promise<GetWalletLatestTacStatusResult> {\n const signerAddress = params.address.toLowerCase() as Address;\n\n const signatureData = await this.getSignature(signerAddress);\n\n const latestToS = await this.getLatestToSVersion();\n let termsAccepted = false;\n\n if (\n signatureData &&\n signatureData.walletAddress.toLowerCase() ===\n signerAddress.toLowerCase() &&\n signatureData.version === latestToS.version\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 return { signed: termsAccepted };\n }\n\n async signTac(params: SignTacParams): Promise<void> {\n const latestToS = await this.getLatestToSVersion();\n\n const signerAddress = (\n await params.signer.getAddress()\n ).toLowerCase() as Address;\n\n const referredByWalletAddress = (\n params.referredByWalletAddress || 'none'\n ).toLowerCase();\n\n try {\n // minimise special characters as they tend to change when signed\n let modifiedText = latestToS.text.replace(/\\t/g, ''); // Remove tabs\n modifiedText = modifiedText.replace(/\\n\\n/g, '\\n'); // Replace double newline with single newline\n const signature = await params.signer.signMessage(modifiedText);\n const response = await this.saveSignatureWithToS(\n signerAddress,\n signature,\n modifiedText,\n latestToS.version,\n referredByWalletAddress,\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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAQyB;AASzB;IAAgD,sCAAU;IAGxD,4BAAY,MAAc,EAAE,cAAuB;QACjD,YAAA,MAAK,YAAC,MAAM,CAAC,SAAC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,EACb,SAAS,EACT,YAAY,EACZ,SAAS,CAAC,OAAO,EACjB,MAAM,CAAC,uBAAuB,CAC/B,EAAA;;wBANK,QAAQ,GAAG,SAMhB;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;;;;;KAEjD;IA7DK;QADL,IAAA,eAAM,EAAC,wCAAwC,CAAC;iEAOhD;IAGK;QADL,IAAA,eAAM,EAAC,6CAA6C,CAAC;sEAuBrD;IAGK;QADL,IAAA,eAAM,EAAC,4BAA4B,CAAC;qDA4BpC;IACH,yBAAC;CAAA,AA1GD,CAAgD,mBAAU,GA0GzD;kBA1GoB,kBAAkB","sourcesContent":["import {\n Address,\n RestClient,\n SignatureData,\n SaveSignatureResult,\n ToSVersionDetails,\n Loggable,\n Logger,\n} from '@reyaxyz/common';\n\nimport {\n GetLatestTacResult,\n GetWalletLatestTacStatusParams,\n GetWalletLatestTacStatusResult,\n SignTacParams,\n} from './types';\n\nexport default class ToSSignatureClient extends RestClient implements Loggable {\n loggingEnabled: boolean = false;\n\n constructor(apiUrl: string, loggingEnabled: boolean) {\n super(apiUrl);\n this.loggingEnabled = loggingEnabled;\n }\n\n private async getSignature(\n walletAddress: Address,\n ): Promise<SignatureData | undefined> {\n const uri = `/api/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 getLatestToSVersion(): Promise<ToSVersionDetails> {\n const uri = `/api/tos/latest-version`;\n return await this.get(uri);\n }\n\n private async saveSignatureWithToS(\n walletAddress: Address,\n signature: string,\n termsOfService: string,\n version: string,\n referredByWalletAddress: string | undefined,\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 formData.append('version', version);\n\n if (referredByWalletAddress) {\n formData.append('referredByWalletAddress', referredByWalletAddress);\n }\n\n const uri = '/api/owner/tos/add-signature';\n return this.post(uri, undefined, formData, undefined);\n }\n\n @Logger('ToSSignatureClient.getLatestTacService')\n async getLatestTacService(): Promise<GetLatestTacResult> {\n const tosDetails = await this.getLatestToSVersion();\n return {\n version: tosDetails.version,\n text: tosDetails.text,\n };\n }\n\n @Logger('ToSSignatureClient.getWalletLatestTacStatus')\n async getWalletLatestTacStatus(\n params: GetWalletLatestTacStatusParams,\n ): Promise<GetWalletLatestTacStatusResult> {\n const signerAddress = params.address.toLowerCase() as Address;\n\n const signatureData = await this.getSignature(signerAddress);\n\n const latestToS = await this.getLatestToSVersion();\n let termsAccepted = false;\n\n if (\n signatureData &&\n signatureData.walletAddress.toLowerCase() ===\n signerAddress.toLowerCase() &&\n signatureData.version === latestToS.version\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 return { signed: termsAccepted };\n }\n\n @Logger('ToSSignatureClient.signTac')\n async signTac(params: SignTacParams): Promise<void> {\n const latestToS = await this.getLatestToSVersion();\n\n const signerAddress = (\n await params.signer.getAddress()\n ).toLowerCase() as Address;\n\n try {\n // minimise special characters as they tend to change when signed\n let modifiedText = latestToS.text.replace(/\\t/g, ''); // Remove tabs\n modifiedText = modifiedText.replace(/\\n\\n/g, '\\n'); // Replace double newline with single newline\n const signature = await params.signer.signMessage(modifiedText);\n const response = await this.saveSignatureWithToS(\n signerAddress,\n signature,\n modifiedText,\n latestToS.version,\n params.referredByWalletAddress,\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"]}
@@ -14,6 +14,12 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
17
23
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
24
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
25
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -54,8 +60,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
54
60
  var common_1 = require("@reyaxyz/common");
55
61
  var ToSSignatureAppClient = /** @class */ (function (_super) {
56
62
  __extends(ToSSignatureAppClient, _super);
57
- function ToSSignatureAppClient() {
58
- return _super !== null && _super.apply(this, arguments) || this;
63
+ function ToSSignatureAppClient(apiUrl, loggingEnabled) {
64
+ var _this = _super.call(this, apiUrl) || this;
65
+ _this.loggingEnabled = false;
66
+ _this.loggingEnabled = loggingEnabled;
67
+ return _this;
59
68
  }
60
69
  ToSSignatureAppClient.prototype.getLatestToSVersion = function () {
61
70
  return __awaiter(this, void 0, void 0, function () {
@@ -115,6 +124,18 @@ var ToSSignatureAppClient = /** @class */ (function (_super) {
115
124
  });
116
125
  });
117
126
  };
127
+ __decorate([
128
+ (0, common_1.Logger)('ToSSignatureAppClient.getLatestToSVersion')
129
+ ], ToSSignatureAppClient.prototype, "getLatestToSVersion", null);
130
+ __decorate([
131
+ (0, common_1.Logger)('ToSSignatureAppClient.getLatestTacService')
132
+ ], ToSSignatureAppClient.prototype, "getLatestTacService", null);
133
+ __decorate([
134
+ (0, common_1.Logger)('ToSSignatureAppClient.getWalletLatestTacStatus')
135
+ ], ToSSignatureAppClient.prototype, "getWalletLatestTacStatus", null);
136
+ __decorate([
137
+ (0, common_1.Logger)('ToSSignatureAppClient.signTac')
138
+ ], ToSSignatureAppClient.prototype, "signTac", null);
118
139
  return ToSSignatureAppClient;
119
140
  }(common_1.RestClient));
120
141
  exports.default = ToSSignatureAppClient;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tos-app/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAgE;AAShE;IAAmD,yCAAU;IAA7D;;IAwCA,CAAC;IAvCe,mDAAmB,GAAjC;;;;;;wBACQ,GAAG,GAAG,yBAAyB,CAAC;wBAC/B,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;4BAA1B,sBAAO,SAAmB,EAAC;;;;KAC5B;IAEK,mDAAmB,GAAzB,UACE,MAA4B;;;;;4BAET,qBAAM,IAAI,CAAC,mBAAmB,EAAE,EAAA;;wBAA7C,UAAU,GAAG,SAAgC;wBACnD,sBAAO;gCACL,OAAO,EAAE,UAAU,CAAC,OAAO;gCAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;gCACrB,OAAO,EAAE,MAAM,CAAC,OAAO;6BACxB,EAAC;;;;KACH;IAEK,wDAAwB,GAA9B;IACE,6DAA6D;IAC7D,MAAyC;;;gBAEzC,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO;wBACzB,OAAA,UAAU,CAAC;4BACT,OAAO,CAAC;gCACN,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE;6BACjC,CAAC,CAAC;wBACL,CAAC,EAAE,IAAI,CAAC;oBAJR,CAIQ,CACT,EAAC;;;KACH;IAEK,uCAAO,GAAb;IACE,6DAA6D;IAC7D,MAAwB;;;gBAExB,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO;wBACzB,OAAA,UAAU,CAAC;4BACT,OAAO,EAAE,CAAC;wBACZ,CAAC,EAAE,IAAI,CAAC;oBAFR,CAEQ,CACT,EAAC;;;KACH;IACH,4BAAC;AAAD,CAAC,AAxCD,CAAmD,mBAAU,GAwC5D","sourcesContent":["import { RestClient, ToSVersionDetails } from '@reyaxyz/common';\nimport {\n GetLatestAppTacResult,\n GetLatestAppTacParam,\n GetWalletLatestAppTacStatusParams,\n GetWalletLatestAppTacStatusResult,\n SignAppTacParams,\n} from './types';\n\nexport default class ToSSignatureAppClient extends RestClient {\n private async getLatestToSVersion(): Promise<ToSVersionDetails> {\n const uri = `/api/tos/latest-version`;\n return await this.get(uri);\n }\n\n async getLatestTacService(\n params: GetLatestAppTacParam,\n ): Promise<GetLatestAppTacResult> {\n const tosDetails = await this.getLatestToSVersion();\n return {\n version: tosDetails.version,\n text: tosDetails.text,\n product: params.product,\n };\n }\n\n async getWalletLatestTacStatus(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n params: GetWalletLatestAppTacStatusParams,\n ): Promise<GetWalletLatestAppTacStatusResult> {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve({\n signed: Math.random() * 100 > 50,\n });\n }, 1000),\n );\n }\n\n async signTac(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n params: SignAppTacParams,\n ): Promise<void> {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1000),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tos-app/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAwE;AAUxE;IACU,yCAAU;IAKlB,+BAAY,MAAc,EAAE,cAAuB;QACjD,YAAA,MAAK,YAAC,MAAM,CAAC,SAAC;QAHhB,oBAAc,GAAY,KAAK,CAAC;QAI9B,KAAI,CAAC,cAAc,GAAG,cAAc,CAAC;;IACvC,CAAC;IAGa,mDA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port {\n GetLatestAppTacResult,\n GetLatestAppTacParam,\n GetWalletLatestAppTacStatusParams,\n GetWalletLatestAppTacStatusResult,\n SignAppTacParams,\n} from './types';\nimport { Loggable } from '@reyaxyz/common';\n\nexport default class ToSSignatureAppClient\n extends RestClient\n implements Loggable\n{\n loggingEnabled: boolean = false;\n\n constructor(apiUrl: string, loggingEnabled: boolean) {\n super(apiUrl);\n this.loggingEnabled = loggingEnabled;\n }\n\n @Logger('ToSSignatureAppClient.getLatestToSVersion')\n private async getLatestToSVersion(): Promise<ToSVersionDetails> {\n const uri = `/api/tos/latest-version`;\n return await this.get(uri);\n }\n\n @Logger('ToSSignatureAppClient.getLatestTacService')\n async getLatestTacService(\n params: GetLatestAppTacParam,\n ): Promise<GetLatestAppTacResult> {\n const tosDetails = await this.getLatestToSVersion();\n return {\n version: tosDetails.version,\n text: tosDetails.text,\n product: params.product,\n };\n }\n\n @Logger('ToSSignatureAppClient.getWalletLatestTacStatus')\n async getWalletLatestTacStatus(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n params: GetWalletLatestAppTacStatusParams,\n ): Promise<GetWalletLatestAppTacStatusResult> {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve({\n signed: Math.random() * 100 > 50,\n });\n }, 1000),\n );\n }\n\n @Logger('ToSSignatureAppClient.signTac')\n async signTac(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n params: SignAppTacParams,\n ): Promise<void> {\n return new Promise((resolve) =>\n setTimeout(() => {\n resolve();\n }, 1000),\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/tos-app/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\n\nexport type GetLatestAppTacResult = {\n version: string;\n text: string;\n product: string;\n};\n\nexport type GetLatestAppTacParam = {\n product: string;\n};\n\nexport type GetWalletLatestAppTacStatusResult = {\n signed: boolean;\n};\n\nexport type GetWalletLatestAppTacStatusParams = {\n address: string;\n product: string;\n};\n\nexport type SignAppTacParams = {\n signer: Signer | JsonRpcSigner;\n version: string;\n product: string;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/tos-app/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\n\nexport type GetLatestAppTacResult = {\n version: string;\n text: string;\n product: 'app.reya.xyz' | 'reya.network';\n};\n\nexport type GetLatestAppTacParam = {\n product: 'app.reya.xyz' | 'reya.network';\n};\n\nexport type GetWalletLatestAppTacStatusResult = {\n signed: boolean;\n};\n\nexport type GetWalletLatestAppTacStatusParams = {\n address: string;\n product: 'app.reya.xyz' | 'reya.network';\n};\n\nexport type SignAppTacParams = {\n signer: Signer | JsonRpcSigner;\n version: string;\n product: 'app.reya.xyz' | 'reya.network';\n};\n"]}
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.WalletClient = void 0;
7
- var constants_1 = require("./helpers/constants");
7
+ var common_1 = require("@reyaxyz/common");
8
8
  var risk_1 = __importDefault(require("./modules/risk"));
9
9
  var tos_1 = __importDefault(require("./modules/tos"));
10
10
  var tos_app_1 = __importDefault(require("./modules/tos-app"));
@@ -13,13 +13,13 @@ var tos_app_1 = __importDefault(require("./modules/tos-app"));
13
13
  */
14
14
  var WalletClient = /** @class */ (function () {
15
15
  function WalletClient() {
16
- this._riskClient = new risk_1.default(WalletClient.config.apiEndpoint);
17
- this._tosSignatureClient = new tos_1.default(WalletClient.config.apiEndpoint);
18
- this._tosSignatureAppClient = new tos_app_1.default(WalletClient.config.apiEndpoint);
16
+ this._riskClient = new risk_1.default(WalletClient.config.apiEndpoint, WalletClient.config.logging);
17
+ this._tosSignatureClient = new tos_1.default(WalletClient.config.apiEndpoint, WalletClient.config.logging);
18
+ this._tosSignatureAppClient = new tos_app_1.default(WalletClient.config.apiEndpoint, WalletClient.config.logging);
19
19
  }
20
20
  WalletClient.configure = function (environment) {
21
21
  WalletClient.config =
22
- constants_1.API_CLIENT_CONFIGS[environment] || constants_1.API_CLIENT_CONFIGS['test'];
22
+ common_1.API_CLIENT_CONFIGS[environment] || common_1.API_CLIENT_CONFIGS['test'];
23
23
  WalletClient.instance = new WalletClient();
24
24
  };
25
25
  WalletClient.getInstance = function () {
@@ -80,7 +80,7 @@ var WalletClient = /** @class */ (function () {
80
80
  enumerable: false,
81
81
  configurable: true
82
82
  });
83
- WalletClient.config = constants_1.API_CLIENT_CONFIGS['test'];
83
+ WalletClient.config = common_1.API_CLIENT_CONFIGS['test'];
84
84
  return WalletClient;
85
85
  }());
86
86
  exports.WalletClient = WalletClient;
@@ -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,8DAAsD;AACtD;;GAEG;AACH;IAOE;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,cAAU,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACnE,IAAI,CAAC,mBAAmB,GAAG,IAAI,aAAkB,CAC/C,YAAY,CAAC,MAAM,CAAC,WAAW,CAChC,CAAC;QACF,IAAI,CAAC,sBAAsB,GAAG,IAAI,iBAAqB,CACrD,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,oBAAI;QAPtB;;;;;;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;IASD,sBAAkB,+BAAe;QAPjC;;;;;;WAMG;aACH;YACE,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC,sBAAsB,CAAC;QAC3D,CAAC;;;OAAA;IApEc,mBAAM,GAAkB,8BAAkB,CAAC,MAAM,CAAC,CAAC;IAqEpE,mBAAC;CAAA,AAvED,IAuEC;AAvEY,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';\nimport ToSSignatureAppClient from './modules/tos-app';\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 private readonly _tosSignatureAppClient: ToSSignatureAppClient;\n\n private constructor() {\n this._riskClient = new RiskClient(WalletClient.config.apiEndpoint);\n this._tosSignatureClient = new ToSSignatureClient(\n WalletClient.config.apiEndpoint,\n );\n this._tosSignatureAppClient = new ToSSignatureAppClient(\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 risk-related operations.\n * @memberof WalletClient\n */\n public static get risk(): RiskClient {\n return WalletClient.getInstance()._riskClient;\n }\n\n /**\n * Provides access to the ToSSignatureClient instance for LGE.\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 /**\n * Provides general access to the ToSSignatureAppClient 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 tosSignatureApp(): ToSSignatureAppClient {\n return WalletClient.getInstance()._tosSignatureAppClient;\n }\n}\n"]}
1
+ {"version":3,"file":"wallet-client.js","sourceRoot":"/","sources":["clients/wallet-client.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AACzB,wDAAwC;AACxC,sDAA+C;AAC/C,8DAAsD;AACtD;;GAEG;AACH;IAOE;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,cAAU,CAC/B,YAAY,CAAC,MAAM,CAAC,WAAW,EAC/B,YAAY,CAAC,MAAM,CAAC,OAAO,CAC5B,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,aAAkB,CAC/C,YAA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C;IA0EpE,mBAAC;CAAA,AA5ED,IA4EC;AA5EY,oCAAY","sourcesContent":["import {\n API_CLIENT_CONFIGS,\n ReyaChainId,\n ServiceConfig,\n} from '@reyaxyz/common';\nimport RiskClient from './modules/risk';\nimport ToSSignatureClient from './modules/tos';\nimport ToSSignatureAppClient from './modules/tos-app';\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 private readonly _tosSignatureAppClient: ToSSignatureAppClient;\n\n private constructor() {\n this._riskClient = new RiskClient(\n WalletClient.config.apiEndpoint,\n WalletClient.config.logging,\n );\n this._tosSignatureClient = new ToSSignatureClient(\n WalletClient.config.apiEndpoint,\n WalletClient.config.logging,\n );\n this._tosSignatureAppClient = new ToSSignatureAppClient(\n WalletClient.config.apiEndpoint,\n WalletClient.config.logging,\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 risk-related operations.\n * @memberof WalletClient\n */\n public static get risk(): RiskClient {\n return WalletClient.getInstance()._riskClient;\n }\n\n /**\n * Provides access to the ToSSignatureClient instance for LGE.\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 /**\n * Provides general access to the ToSSignatureAppClient 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 tosSignatureApp(): ToSSignatureAppClient {\n return WalletClient.getInstance()._tosSignatureAppClient;\n }\n}\n"]}
@@ -1,6 +1,8 @@
1
- import { RestClient } from '@reyaxyz/common';
1
+ import { Loggable, RestClient } from '@reyaxyz/common';
2
2
  import { CheckForRiskWalletResult, CheckForRiskyWalletParams } from './types';
3
- export default class RiskClient extends RestClient {
3
+ export default class RiskClient extends RestClient implements Loggable {
4
+ loggingEnabled: boolean;
5
+ constructor(apiUrl: string, loggingEnabled: boolean);
4
6
  checkForRiskWallet(params: CheckForRiskyWalletParams): Promise<CheckForRiskWalletResult>;
5
7
  }
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/risk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,iBAAiB,CAAC;AAGhE,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAE9E,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAU;IAC1C,kBAAkB,CACtB,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,wBAAwB,CAAC;CAUrC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/risk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAE9E,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAW,YAAW,QAAQ;IACpE,cAAc,EAAE,OAAO,CAAS;gBAEpB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO;IAM7C,kBAAkB,CACtB,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,wBAAwB,CAAC;CAUrC"}
@@ -1,6 +1,8 @@
1
- import { RestClient } from '@reyaxyz/common';
1
+ import { RestClient, Loggable } from '@reyaxyz/common';
2
2
  import { GetLatestTacResult, GetWalletLatestTacStatusParams, GetWalletLatestTacStatusResult, SignTacParams } from './types';
3
- export default class ToSSignatureClient extends RestClient {
3
+ export default class ToSSignatureClient extends RestClient implements Loggable {
4
+ loggingEnabled: boolean;
5
+ constructor(apiUrl: string, loggingEnabled: boolean);
4
6
  private getSignature;
5
7
  private getLatestToSVersion;
6
8
  private saveSignatureWithToS;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAIX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,8BAA8B,EAC9B,8BAA8B,EAC9B,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;YAC1C,YAAY;YAQZ,mBAAmB;YAKnB,oBAAoB;IAmB5B,mBAAmB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQlD,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAsBpC,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAgCpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAIV,QAAQ,EAET,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,kBAAkB,EAClB,8BAA8B,EAC9B,8BAA8B,EAC9B,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAW,YAAW,QAAQ;IAC5E,cAAc,EAAE,OAAO,CAAS;gBAEpB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO;YAKrC,YAAY;YAQZ,mBAAmB;YAKnB,oBAAoB;IAuB5B,mBAAmB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IASlD,wBAAwB,CAC5B,MAAM,EAAE,8BAA8B,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAuBpC,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CA4BpD"}
@@ -1,6 +1,9 @@
1
1
  import { RestClient } from '@reyaxyz/common';
2
2
  import { GetLatestAppTacResult, GetLatestAppTacParam, GetWalletLatestAppTacStatusParams, GetWalletLatestAppTacStatusResult, SignAppTacParams } from './types';
3
- export default class ToSSignatureAppClient extends RestClient {
3
+ import { Loggable } from '@reyaxyz/common';
4
+ export default class ToSSignatureAppClient extends RestClient implements Loggable {
5
+ loggingEnabled: boolean;
6
+ constructor(apiUrl: string, loggingEnabled: boolean);
4
7
  private getLatestToSVersion;
5
8
  getLatestTacService(params: GetLatestAppTacParam): Promise<GetLatestAppTacResult>;
6
9
  getWalletLatestTacStatus(params: GetWalletLatestAppTacStatusParams): Promise<GetWalletLatestAppTacStatusResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/tos-app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,iCAAiC,EACjC,iCAAiC,EACjC,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU;YAC7C,mBAAmB;IAK3B,mBAAmB,CACvB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,qBAAqB,CAAC;IAS3B,wBAAwB,CAE5B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAUvC,OAAO,CAEX,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,IAAI,CAAC;CAOjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/tos-app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAqB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,iCAAiC,EACjC,iCAAiC,EACjC,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,qBACnB,SAAQ,UACR,YAAW,QAAQ;IAEnB,cAAc,EAAE,OAAO,CAAS;gBAEpB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO;YAMrC,mBAAmB;IAM3B,mBAAmB,CACvB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,qBAAqB,CAAC;IAU3B,wBAAwB,CAE5B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAWvC,OAAO,CAEX,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,IAAI,CAAC;CAOjB"}
@@ -2,21 +2,21 @@ import { JsonRpcSigner, Signer } from 'ethers';
2
2
  export type GetLatestAppTacResult = {
3
3
  version: string;
4
4
  text: string;
5
- product: string;
5
+ product: 'app.reya.xyz' | 'reya.network';
6
6
  };
7
7
  export type GetLatestAppTacParam = {
8
- product: string;
8
+ product: 'app.reya.xyz' | 'reya.network';
9
9
  };
10
10
  export type GetWalletLatestAppTacStatusResult = {
11
11
  signed: boolean;
12
12
  };
13
13
  export type GetWalletLatestAppTacStatusParams = {
14
14
  address: string;
15
- product: string;
15
+ product: 'app.reya.xyz' | 'reya.network';
16
16
  };
17
17
  export type SignAppTacParams = {
18
18
  signer: Signer | JsonRpcSigner;
19
19
  version: string;
20
- product: string;
20
+ product: 'app.reya.xyz' | 'reya.network';
21
21
  };
22
22
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/tos-app/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/tos-app/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,cAAc,GAAG,cAAc,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,cAAc,GAAG,cAAc,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,cAAc,GAAG,cAAc,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,cAAc,GAAG,cAAc,CAAC;CAC1C,CAAC"}
@@ -1,5 +1,4 @@
1
- import { ServiceConfig } from './helpers/constants';
2
- import { ReyaChainId } from '@reyaxyz/common';
1
+ import { ReyaChainId, ServiceConfig } from '@reyaxyz/common';
3
2
  import RiskClient from './modules/risk';
4
3
  import ToSSignatureClient from './modules/tos';
5
4
  import ToSSignatureAppClient from './modules/tos-app';
@@ -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,OAAO,qBAAqB,MAAM,mBAAmB,CAAC;AACtD;;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;IACzD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAwB;IAE/D,OAAO;WAUO,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,IAAI,IAAI,UAAU,CAEnC;IAED;;;;;;OAMG;IACH,WAAkB,YAAY,IAAI,kBAAkB,CAEnD;IAED;;;;;;OAMG;IACH,WAAkB,eAAe,IAAI,qBAAqB,CAEzD;CACF"}
1
+ {"version":3,"file":"wallet-client.d.ts","sourceRoot":"/","sources":["clients/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,UAAU,MAAM,gBAAgB,CAAC;AACxC,OAAO,kBAAkB,MAAM,eAAe,CAAC;AAC/C,OAAO,qBAAqB,MAAM,mBAAmB,CAAC;AACtD;;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;IACzD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAwB;IAE/D,OAAO;WAeO,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,IAAI,IAAI,UAAU,CAEnC;IAED;;;;;;OAMG;IACH,WAAkB,YAAY,IAAI,kBAAkB,CAEnD;IAED;;;;;;OAMG;IACH,WAAkB,eAAe,IAAI,qBAAqB,CAEzD;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/wallet-sdk",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
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.74.0",
36
+ "@reyaxyz/common": "0.74.1",
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": "6aa150e20b7e038ca1b17c8cbaa8397126afa955"
42
+ "gitHead": "d5d20f398d307b4851b982002017a6e89ac55ce5"
43
43
  }
@@ -1,9 +1,22 @@
1
- import { RestClient, TRMRiskAssessment } from '@reyaxyz/common';
1
+ import {
2
+ Loggable,
3
+ Logger,
4
+ RestClient,
5
+ TRMRiskAssessment,
6
+ } from '@reyaxyz/common';
2
7
  import { isWalletRisky } from '../../helpers/isWalletRisky';
3
8
 
4
9
  import { CheckForRiskWalletResult, CheckForRiskyWalletParams } from './types';
5
10
 
6
- export default class RiskClient extends RestClient {
11
+ export default class RiskClient extends RestClient implements Loggable {
12
+ loggingEnabled: boolean = false;
13
+
14
+ constructor(apiUrl: string, loggingEnabled: boolean) {
15
+ super(apiUrl);
16
+ this.loggingEnabled = loggingEnabled;
17
+ }
18
+
19
+ @Logger('RiskClient.checkForRiskWallet')
7
20
  async checkForRiskWallet(
8
21
  params: CheckForRiskyWalletParams,
9
22
  ): Promise<CheckForRiskWalletResult> {
@@ -4,7 +4,10 @@ import {
4
4
  SignatureData,
5
5
  SaveSignatureResult,
6
6
  ToSVersionDetails,
7
+ Loggable,
8
+ Logger,
7
9
  } from '@reyaxyz/common';
10
+
8
11
  import {
9
12
  GetLatestTacResult,
10
13
  GetWalletLatestTacStatusParams,
@@ -12,7 +15,14 @@ import {
12
15
  SignTacParams,
13
16
  } from './types';
14
17
 
15
- export default class ToSSignatureClient extends RestClient {
18
+ export default class ToSSignatureClient extends RestClient implements Loggable {
19
+ loggingEnabled: boolean = false;
20
+
21
+ constructor(apiUrl: string, loggingEnabled: boolean) {
22
+ super(apiUrl);
23
+ this.loggingEnabled = loggingEnabled;
24
+ }
25
+
16
26
  private async getSignature(
17
27
  walletAddress: Address,
18
28
  ): Promise<SignatureData | undefined> {
@@ -31,7 +41,7 @@ export default class ToSSignatureClient extends RestClient {
31
41
  signature: string,
32
42
  termsOfService: string,
33
43
  version: string,
34
- referredByWalletAddress: string,
44
+ referredByWalletAddress: string | undefined,
35
45
  ): Promise<SaveSignatureResult> {
36
46
  // Build formData object.
37
47
  const formData = new FormData();
@@ -39,12 +49,16 @@ export default class ToSSignatureClient extends RestClient {
39
49
  formData.append('walletAddress', walletAddress);
40
50
  formData.append('message', termsOfService);
41
51
  formData.append('version', version);
42
- formData.append('referredByWalletAddress', referredByWalletAddress);
52
+
53
+ if (referredByWalletAddress) {
54
+ formData.append('referredByWalletAddress', referredByWalletAddress);
55
+ }
43
56
 
44
57
  const uri = '/api/owner/tos/add-signature';
45
58
  return this.post(uri, undefined, formData, undefined);
46
59
  }
47
60
 
61
+ @Logger('ToSSignatureClient.getLatestTacService')
48
62
  async getLatestTacService(): Promise<GetLatestTacResult> {
49
63
  const tosDetails = await this.getLatestToSVersion();
50
64
  return {
@@ -53,6 +67,7 @@ export default class ToSSignatureClient extends RestClient {
53
67
  };
54
68
  }
55
69
 
70
+ @Logger('ToSSignatureClient.getWalletLatestTacStatus')
56
71
  async getWalletLatestTacStatus(
57
72
  params: GetWalletLatestTacStatusParams,
58
73
  ): Promise<GetWalletLatestTacStatusResult> {
@@ -77,6 +92,7 @@ export default class ToSSignatureClient extends RestClient {
77
92
  return { signed: termsAccepted };
78
93
  }
79
94
 
95
+ @Logger('ToSSignatureClient.signTac')
80
96
  async signTac(params: SignTacParams): Promise<void> {
81
97
  const latestToS = await this.getLatestToSVersion();
82
98
 
@@ -84,10 +100,6 @@ export default class ToSSignatureClient extends RestClient {
84
100
  await params.signer.getAddress()
85
101
  ).toLowerCase() as Address;
86
102
 
87
- const referredByWalletAddress = (
88
- params.referredByWalletAddress || 'none'
89
- ).toLowerCase();
90
-
91
103
  try {
92
104
  // minimise special characters as they tend to change when signed
93
105
  let modifiedText = latestToS.text.replace(/\t/g, ''); // Remove tabs
@@ -98,7 +110,7 @@ export default class ToSSignatureClient extends RestClient {
98
110
  signature,
99
111
  modifiedText,
100
112
  latestToS.version,
101
- referredByWalletAddress,
113
+ params.referredByWalletAddress,
102
114
  );
103
115
 
104
116
  if (!response.signatureSavedSuccessfully) {
@@ -1,4 +1,4 @@
1
- import { RestClient, ToSVersionDetails } from '@reyaxyz/common';
1
+ import { Logger, RestClient, ToSVersionDetails } from '@reyaxyz/common';
2
2
  import {
3
3
  GetLatestAppTacResult,
4
4
  GetLatestAppTacParam,
@@ -6,13 +6,26 @@ import {
6
6
  GetWalletLatestAppTacStatusResult,
7
7
  SignAppTacParams,
8
8
  } from './types';
9
+ import { Loggable } from '@reyaxyz/common';
9
10
 
10
- export default class ToSSignatureAppClient extends RestClient {
11
+ export default class ToSSignatureAppClient
12
+ extends RestClient
13
+ implements Loggable
14
+ {
15
+ loggingEnabled: boolean = false;
16
+
17
+ constructor(apiUrl: string, loggingEnabled: boolean) {
18
+ super(apiUrl);
19
+ this.loggingEnabled = loggingEnabled;
20
+ }
21
+
22
+ @Logger('ToSSignatureAppClient.getLatestToSVersion')
11
23
  private async getLatestToSVersion(): Promise<ToSVersionDetails> {
12
24
  const uri = `/api/tos/latest-version`;
13
25
  return await this.get(uri);
14
26
  }
15
27
 
28
+ @Logger('ToSSignatureAppClient.getLatestTacService')
16
29
  async getLatestTacService(
17
30
  params: GetLatestAppTacParam,
18
31
  ): Promise<GetLatestAppTacResult> {
@@ -24,6 +37,7 @@ export default class ToSSignatureAppClient extends RestClient {
24
37
  };
25
38
  }
26
39
 
40
+ @Logger('ToSSignatureAppClient.getWalletLatestTacStatus')
27
41
  async getWalletLatestTacStatus(
28
42
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
43
  params: GetWalletLatestAppTacStatusParams,
@@ -37,6 +51,7 @@ export default class ToSSignatureAppClient extends RestClient {
37
51
  );
38
52
  }
39
53
 
54
+ @Logger('ToSSignatureAppClient.signTac')
40
55
  async signTac(
41
56
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
57
  params: SignAppTacParams,
@@ -3,11 +3,11 @@ import { JsonRpcSigner, Signer } from 'ethers';
3
3
  export type GetLatestAppTacResult = {
4
4
  version: string;
5
5
  text: string;
6
- product: string;
6
+ product: 'app.reya.xyz' | 'reya.network';
7
7
  };
8
8
 
9
9
  export type GetLatestAppTacParam = {
10
- product: string;
10
+ product: 'app.reya.xyz' | 'reya.network';
11
11
  };
12
12
 
13
13
  export type GetWalletLatestAppTacStatusResult = {
@@ -16,11 +16,11 @@ export type GetWalletLatestAppTacStatusResult = {
16
16
 
17
17
  export type GetWalletLatestAppTacStatusParams = {
18
18
  address: string;
19
- product: string;
19
+ product: 'app.reya.xyz' | 'reya.network';
20
20
  };
21
21
 
22
22
  export type SignAppTacParams = {
23
23
  signer: Signer | JsonRpcSigner;
24
24
  version: string;
25
- product: string;
25
+ product: 'app.reya.xyz' | 'reya.network';
26
26
  };
@@ -1,5 +1,8 @@
1
- import { API_CLIENT_CONFIGS, ServiceConfig } from './helpers/constants';
2
- import { ReyaChainId } from '@reyaxyz/common';
1
+ import {
2
+ API_CLIENT_CONFIGS,
3
+ ReyaChainId,
4
+ ServiceConfig,
5
+ } from '@reyaxyz/common';
3
6
  import RiskClient from './modules/risk';
4
7
  import ToSSignatureClient from './modules/tos';
5
8
  import ToSSignatureAppClient from './modules/tos-app';
@@ -14,12 +17,17 @@ export class WalletClient {
14
17
  private readonly _tosSignatureAppClient: ToSSignatureAppClient;
15
18
 
16
19
  private constructor() {
17
- this._riskClient = new RiskClient(WalletClient.config.apiEndpoint);
20
+ this._riskClient = new RiskClient(
21
+ WalletClient.config.apiEndpoint,
22
+ WalletClient.config.logging,
23
+ );
18
24
  this._tosSignatureClient = new ToSSignatureClient(
19
25
  WalletClient.config.apiEndpoint,
26
+ WalletClient.config.logging,
20
27
  );
21
28
  this._tosSignatureAppClient = new ToSSignatureAppClient(
22
29
  WalletClient.config.apiEndpoint,
30
+ WalletClient.config.logging,
23
31
  );
24
32
  }
25
33
 
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.API_CLIENT_CONFIGS = void 0;
4
- var common_1 = require("@reyaxyz/common");
5
- exports.API_CLIENT_CONFIGS = {
6
- local: {
7
- chain: common_1.ReyaChainId.reyaCronos,
8
- apiEndpoint: 'http://localhost:3000',
9
- environment: 'local',
10
- timeout: common_1.API_TIMEOUT,
11
- },
12
- production: {
13
- chain: common_1.ReyaChainId.reyaNetwork,
14
- apiEndpoint: 'https://api.reya.xyz',
15
- environment: 'production',
16
- timeout: common_1.API_TIMEOUT,
17
- },
18
- test: {
19
- chain: common_1.ReyaChainId.reyaCronos,
20
- apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
21
- environment: 'test',
22
- timeout: common_1.API_TIMEOUT,
23
- },
24
- };
25
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/helpers/constants.ts"],"names":[],"mappings":";;;AAAA,0CAA2D;AAU9C,QAAA,kBAAkB,GAA8C;IAC3E,KAAK,EAAE;QACL,KAAK,EAAE,oBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,uBAAuB;QACpC,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,oBAAW;KACrB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,oBAAW,CAAC,WAAW;QAC9B,WAAW,EAAE,sBAAsB;QACnC,WAAW,EAAE,YAAY;QACzB,OAAO,EAAE,oBAAW;KACrB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,oBAAW,CAAC,UAAU;QAC7B,WAAW,EAAE,kDAAkD;QAC/D,WAAW,EAAE,MAAM;QACnB,OAAO,EAAE,oBAAW;KACrB;CACF,CAAC","sourcesContent":["import { API_TIMEOUT, ReyaChainId } from '@reyaxyz/common';\n\ntype ServiceEnvironment = 'production' | 'test' | 'local';\nexport interface ServiceConfig {\n chain: ReyaChainId;\n apiEndpoint: 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 environment: 'local',\n timeout: API_TIMEOUT,\n },\n production: {\n chain: ReyaChainId.reyaNetwork,\n apiEndpoint: 'https://api.reya.xyz',\n environment: 'production',\n timeout: API_TIMEOUT,\n },\n test: {\n chain: ReyaChainId.reyaCronos,\n apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',\n environment: 'test',\n timeout: API_TIMEOUT,\n },\n};\n"]}
@@ -1,11 +0,0 @@
1
- import { ReyaChainId } from '@reyaxyz/common';
2
- type ServiceEnvironment = 'production' | 'test' | 'local';
3
- export interface ServiceConfig {
4
- chain: ReyaChainId;
5
- apiEndpoint: string;
6
- environment: ServiceEnvironment;
7
- timeout: number;
8
- }
9
- export declare const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig>;
10
- export {};
11
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
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,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAmBxE,CAAC"}
@@ -1,30 +0,0 @@
1
- import { API_TIMEOUT, ReyaChainId } from '@reyaxyz/common';
2
-
3
- type ServiceEnvironment = 'production' | 'test' | 'local';
4
- export interface ServiceConfig {
5
- chain: ReyaChainId;
6
- apiEndpoint: string;
7
- environment: ServiceEnvironment; // Configuration for SDK, such as base URL for the REST API
8
- timeout: number; // Optional timeout for API requests
9
- }
10
-
11
- export const API_CLIENT_CONFIGS: Record<ServiceEnvironment, ServiceConfig> = {
12
- local: {
13
- chain: ReyaChainId.reyaCronos,
14
- apiEndpoint: 'http://localhost:3000',
15
- environment: 'local',
16
- timeout: API_TIMEOUT,
17
- },
18
- production: {
19
- chain: ReyaChainId.reyaNetwork,
20
- apiEndpoint: 'https://api.reya.xyz',
21
- environment: 'production',
22
- timeout: API_TIMEOUT,
23
- },
24
- test: {
25
- chain: ReyaChainId.reyaCronos,
26
- apiEndpoint: 'https://m8mjgmqmte.eu-central-1.awsapprunner.com',
27
- environment: 'test',
28
- timeout: API_TIMEOUT,
29
- },
30
- };