@grvt/sdk 0.0.2 → 0.0.4

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/api/sanitizer.js CHANGED
@@ -21,6 +21,8 @@ function sanitizeDepositHistoryResponse(response) {
21
21
  ...deposit,
22
22
  from_address: sanitizeNullableAddress(deposit.from_address),
23
23
  to_account_id: sanitizeNullableAddress(deposit.to_account_id),
24
+ l_1_hash: sanitizeNullableTransactionHash(deposit.l_1_hash),
25
+ l_2_hash: sanitizeNullableTransactionHash(deposit.l_2_hash),
24
26
  })),
25
27
  };
26
28
  }
@@ -31,10 +33,15 @@ function sanitizeWithdrawalHistoryResponse(response) {
31
33
  ...withdrawal,
32
34
  from_account_id: sanitizeNullableAddress(withdrawal.from_account_id),
33
35
  to_eth_address: sanitizeNullableAddress(withdrawal.to_eth_address),
36
+ l_1_hash: sanitizeNullableTransactionHash(withdrawal.l_1_hash),
37
+ l_2_hash: sanitizeNullableTransactionHash(withdrawal.l_2_hash),
34
38
  })),
35
39
  };
36
40
  }
37
41
  function sanitizeNullableAddress(address) {
38
42
  return address ? (0, address_1.sanitizeEvmAddress)(address) : undefined;
39
43
  }
44
+ function sanitizeNullableTransactionHash(transactionHash) {
45
+ return transactionHash ? (0, address_1.sanitizeTransactionHash)(transactionHash) : undefined;
46
+ }
40
47
  //# sourceMappingURL=sanitizer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../src/api/sanitizer.ts"],"names":[],"mappings":";;AAOA,0EAWC;AAED,wEAWC;AAED,8EAWC;AAvCD,8CAAsD;AAEtD,SAAgB,+BAA+B,CAC7C,QAAqC;IAErC,OAAO;QACL,GAAG,QAAQ;QACX,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC1C,GAAG,QAAQ;YACX,eAAe,EAAE,uBAAuB,CAAC,QAAQ,CAAC,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C;IAC1E,OAAO,eAAe,CAAC,CAAC,CAAC,IAAA,iCAAuB,EAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grvt/sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "TypeScript SDK for GRVT",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -8,3 +8,13 @@
8
8
  * @returns The sanitized address
9
9
  */
10
10
  export declare function sanitizeEvmAddress(address: string): string;
11
+ /**
12
+ * Sanitize a transaction hash to:
13
+ * - trim the transaction hash
14
+ * - lowercase the transaction hash
15
+ * - add 0 padding to the left if it's less than 64 characters
16
+ * - add 0x prefix if it doesn't have it
17
+ * @param transactionHash - The transaction hash to sanitize
18
+ * @returns The sanitized transaction hash
19
+ */
20
+ export declare function sanitizeTransactionHash(transactionHash: string): string;
package/utils/address.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sanitizeEvmAddress = sanitizeEvmAddress;
4
+ exports.sanitizeTransactionHash = sanitizeTransactionHash;
4
5
  /**
5
6
  * Sanitize an EVM address to:
6
7
  * - trim the address
@@ -23,4 +24,24 @@ function sanitizeEvmAddress(address) {
23
24
  address = address.toLowerCase();
24
25
  return address;
25
26
  }
27
+ /**
28
+ * Sanitize a transaction hash to:
29
+ * - trim the transaction hash
30
+ * - lowercase the transaction hash
31
+ * - add 0 padding to the left if it's less than 64 characters
32
+ * - add 0x prefix if it doesn't have it
33
+ * @param transactionHash - The transaction hash to sanitize
34
+ * @returns The sanitized transaction hash
35
+ */
36
+ function sanitizeTransactionHash(transactionHash) {
37
+ // 1. Trim the transaction hash
38
+ transactionHash = transactionHash.trim();
39
+ // 2. Remove the 0x prefix if it exists
40
+ transactionHash = transactionHash.replace(/^0x/, '');
41
+ // 3. Add 0 padding to the left if it's less than 64 characters
42
+ transactionHash = transactionHash.padStart(64, '0');
43
+ // 4. Add 0x prefix if it doesn't have it
44
+ transactionHash = `0x${transactionHash}`;
45
+ return transactionHash;
46
+ }
26
47
  //# sourceMappingURL=address.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":";;AASA,gDAYC;AArBD;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAChD,sBAAsB;IACtB,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACzB,uCAAuC;IACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,+DAA+D;IAC/D,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACpC,yCAAyC;IACzC,OAAO,GAAG,KAAK,OAAO,EAAE,CAAC;IACzB,gEAAgE;IAChE,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":";;AASA,gDAYC;AAWD,0DAUC;AA1CD;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAChD,sBAAsB;IACtB,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACzB,uCAAuC;IACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,+DAA+D;IAC/D,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACpC,yCAAyC;IACzC,OAAO,GAAG,KAAK,OAAO,EAAE,CAAC;IACzB,gEAAgE;IAChE,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;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