@reyaxyz/wallet-sdk 0.9.14 → 0.10.1
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/modules/tos/index.js +5 -3
- package/dist/clients/modules/tos/index.js.map +1 -1
- package/dist/clients/modules/tos/types.js.map +1 -1
- package/dist/clients/types.js +1 -0
- package/dist/clients/types.js.map +1 -1
- package/dist/types/clients/modules/tos/index.d.ts.map +1 -1
- package/dist/types/clients/modules/tos/types.d.ts +1 -0
- package/dist/types/clients/modules/tos/types.d.ts.map +1 -1
- package/dist/types/clients/types.d.ts +1 -0
- package/dist/types/clients/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/modules/tos/index.ts +8 -0
- package/src/clients/modules/tos/types.ts +1 -0
- package/src/clients/types.ts +1 -0
|
@@ -85,7 +85,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
|
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
|
-
ToSSignatureClient.prototype.saveSignatureWithToS = function (walletAddress, signature, termsOfService, version) {
|
|
88
|
+
ToSSignatureClient.prototype.saveSignatureWithToS = function (walletAddress, signature, termsOfService, version, referredByWalletAddress) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
90
|
var formData, uri;
|
|
91
91
|
return __generator(this, function (_a) {
|
|
@@ -94,6 +94,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
|
|
|
94
94
|
formData.append('walletAddress', walletAddress);
|
|
95
95
|
formData.append('message', termsOfService);
|
|
96
96
|
formData.append('version', version);
|
|
97
|
+
formData.append('referredByWalletAddress', referredByWalletAddress);
|
|
97
98
|
uri = '/api/owner/tos/add-signature';
|
|
98
99
|
return [2 /*return*/, this.post(uri, undefined, formData, undefined)];
|
|
99
100
|
});
|
|
@@ -144,7 +145,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
|
|
|
144
145
|
};
|
|
145
146
|
ToSSignatureClient.prototype.signTac = function (params) {
|
|
146
147
|
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
-
var latestToS, signerAddress, modifiedText, signature, response, error_1;
|
|
148
|
+
var latestToS, signerAddress, referredByWalletAddress, modifiedText, signature, response, error_1;
|
|
148
149
|
return __generator(this, function (_a) {
|
|
149
150
|
switch (_a.label) {
|
|
150
151
|
case 0: return [4 /*yield*/, this.getLatestToSVersion()];
|
|
@@ -153,6 +154,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
|
|
|
153
154
|
return [4 /*yield*/, params.signer.getAddress()];
|
|
154
155
|
case 2:
|
|
155
156
|
signerAddress = (_a.sent()).toLowerCase();
|
|
157
|
+
referredByWalletAddress = (params.referredByWalletAddress || 'none').toLowerCase();
|
|
156
158
|
_a.label = 3;
|
|
157
159
|
case 3:
|
|
158
160
|
_a.trys.push([3, 6, , 7]);
|
|
@@ -161,7 +163,7 @@ var ToSSignatureClient = /** @class */ (function (_super) {
|
|
|
161
163
|
return [4 /*yield*/, params.signer.signMessage(modifiedText)];
|
|
162
164
|
case 4:
|
|
163
165
|
signature = _a.sent();
|
|
164
|
-
return [4 /*yield*/, this.saveSignatureWithToS(signerAddress, signature, modifiedText, latestToS.version)];
|
|
166
|
+
return [4 /*yield*/, this.saveSignatureWithToS(signerAddress, signature, modifiedText, latestToS.version, referredByWalletAddress)];
|
|
165
167
|
case 5:
|
|
166
168
|
response = _a.sent();
|
|
167
169
|
if (!response.signatureSavedSuccessfully) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AAQzB;IAAgD,sCAAU;IAA1D;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/tos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AM,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/tos/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\n\nexport type GetLatestTacResult = {\n version: string;\n text: string;\n};\n\nexport type GetWalletLatestTacStatusResult = {\n signed: boolean;\n};\n\nexport type GetWalletLatestTacStatusParams = {\n address: string;\n};\n\nexport type SignTacParams = {\n signer: Signer | JsonRpcSigner;\n version: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/tos/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\n\nexport type GetLatestTacResult = {\n version: string;\n text: string;\n};\n\nexport type GetWalletLatestTacStatusResult = {\n signed: boolean;\n};\n\nexport type GetWalletLatestTacStatusParams = {\n address: string;\n};\n\nexport type SignTacParams = {\n signer: Signer | JsonRpcSigner;\n version: string;\n referredByWalletAddress?: string;\n};\n"]}
|
package/dist/clients/types.js
CHANGED
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./modules/risk/types"), exports);
|
|
18
18
|
__exportStar(require("./modules/tos/types"), exports);
|
|
19
|
+
__exportStar(require("./modules/tos-app/types"), exports);
|
|
19
20
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,sDAAoC","sourcesContent":["export * from './modules/risk/types';\nexport * from './modules/tos/types';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,sDAAoC;AACpC,0DAAwC","sourcesContent":["export * from './modules/risk/types';\nexport * from './modules/tos/types';\nexport * from './modules/tos-app/types';\n"]}
|
|
@@ -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;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/tos/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/tos/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/types.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/wallet-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
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.74.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": "6aa150e20b7e038ca1b17c8cbaa8397126afa955"
|
|
43
43
|
}
|
|
@@ -31,6 +31,7 @@ export default class ToSSignatureClient extends RestClient {
|
|
|
31
31
|
signature: string,
|
|
32
32
|
termsOfService: string,
|
|
33
33
|
version: string,
|
|
34
|
+
referredByWalletAddress: string,
|
|
34
35
|
): Promise<SaveSignatureResult> {
|
|
35
36
|
// Build formData object.
|
|
36
37
|
const formData = new FormData();
|
|
@@ -38,6 +39,7 @@ export default class ToSSignatureClient extends RestClient {
|
|
|
38
39
|
formData.append('walletAddress', walletAddress);
|
|
39
40
|
formData.append('message', termsOfService);
|
|
40
41
|
formData.append('version', version);
|
|
42
|
+
formData.append('referredByWalletAddress', referredByWalletAddress);
|
|
41
43
|
|
|
42
44
|
const uri = '/api/owner/tos/add-signature';
|
|
43
45
|
return this.post(uri, undefined, formData, undefined);
|
|
@@ -77,10 +79,15 @@ export default class ToSSignatureClient extends RestClient {
|
|
|
77
79
|
|
|
78
80
|
async signTac(params: SignTacParams): Promise<void> {
|
|
79
81
|
const latestToS = await this.getLatestToSVersion();
|
|
82
|
+
|
|
80
83
|
const signerAddress = (
|
|
81
84
|
await params.signer.getAddress()
|
|
82
85
|
).toLowerCase() as Address;
|
|
83
86
|
|
|
87
|
+
const referredByWalletAddress = (
|
|
88
|
+
params.referredByWalletAddress || 'none'
|
|
89
|
+
).toLowerCase();
|
|
90
|
+
|
|
84
91
|
try {
|
|
85
92
|
// minimise special characters as they tend to change when signed
|
|
86
93
|
let modifiedText = latestToS.text.replace(/\t/g, ''); // Remove tabs
|
|
@@ -91,6 +98,7 @@ export default class ToSSignatureClient extends RestClient {
|
|
|
91
98
|
signature,
|
|
92
99
|
modifiedText,
|
|
93
100
|
latestToS.version,
|
|
101
|
+
referredByWalletAddress,
|
|
94
102
|
);
|
|
95
103
|
|
|
96
104
|
if (!response.signatureSavedSuccessfully) {
|
package/src/clients/types.ts
CHANGED